WebGL map rendering engine for creative cartography
Bugfixes
New Features + Improvements
font.background
block:
font.background.color
: text box fill colorfont.background.alpha
: optionally modify box fill alphafont.background.stroke.color
: text box stroke colorfont.background.stroke.alpha
: optionally modify box stroke alphafont.background.stroke.width
: text box stroke width (defaults to 1px
)font.underline
underline: true
to enable text underline draw:
text:
font:
...
background:
color: white
stroke:
color: red
width: 2px
underline: true
fonts:
Open Sans:
url: fonts/Open Sans.woff2
weight: 200 800
weight
, e.g. mapping font weight to building heights:
weight: |
function() {
return (feature.height||0) * 2 + 400;
}
attribution
property on data sources, which when present will add a Leaflet attribution control. Thanks @bdon! sources:
tilezen:
type: MVT
url: https://tile.nextzen.org/tilezen/vector/v1/512/all/{z}/{x}/{y}.mvt
attribution: Tiles by <a href="https://www.nextzen.org/" target="_blank">Nextzen</a>
...
Bug Fixes / Internal
flatMap()
New Functionality
wireframe: true
to draw geometry in a wireframe mode, helpful for seeing how Tangram converts feature geometries into renderable GL triangles, and debugging issues with suchconst layer = Tangram.leafletLayer({
scene: 'scene.yaml',
debug: {
wireframe: true // enable for wireframe rendering mode
}
});
Bug Fixes
opaque
blendingall_layers
flag set #747 77b9edbInternal
geojson-vt
to v3.2.1New Functionality
style
declaration, the shaders
block can now contain a new entry called attributes
-- a mapping of names to properties of custom vertex attributes. Those new attributes are given values in draw
groups by assigning a value to the attribute's name in a new attributes
block, and are then available inside shader blocks
. All together, the new syntax looks like this:
buildings:
base: polygons
shaders:
attributes:
height:
type: float
blocks:
color: |
// Use the custom attribute's varying to shade by height
color.rgb = vec3(min(height / 100., 1.), 0., 0.);
draw:
# use default draw parameters to set the height attribute value from the height feature property
attributes:
height: function() { return feature.height; }
draw
group within layers
, as with all other draw parameters.custom: function(){ return feature.custom; }
), a single value (custom: 5
), or zoom-interpolated values (custom: [[14, 50], [15, 150], [16, 300]]
).type: float
in the attribute definition) are supported at this time (other attribute types may be supported in the future).alpha
parameter inside draw
groups allows the scene author to set only the alpha channel of a color, independently of the RGB channels. This is useful for cases such as:
draw
groups where an alpha
parameter is present, its value will override the alpha channel set by the corresponding color parameter. For example:
translucent_polygons:
color: red
alpha: 0.5 # red polygon with 50% opacity
alpha
parameter is available for polygons
(fill color
), lines
(inline and outline color
), points (fill and outline color
), text
(font fill
and stroke color
), and raster
(color
).alpha
values can be set as a single value (alpha: 0.5
), zoom-interpolated values (alpha: [[14, 0.5], [16, 1]]
), or JS function (alpha: function(){ return feature.height/200; }
)raster
-based styles to blend/base default styles 4609a89
Bug Fixes
Internal
scene.config.styles
) with blend/base default styles 824ec12Improvements
Bug Fixes
size: function() { ... }
) on high-density displays (previously, display density scaling wasn't applied, so these fonts would be too small on > 1x displays). feca756 9406e5dNew Features
styles
for all combinations of blend
and base
#719
blend_order
to be set at the draw
level in v0.18.0.styles
are now included, to make it easier to use the different blend
modes without having to write boilerplate styles. For each combination of blend
mode (opaque
, overlay
, etc.) and style base
(polygons
, lines
, etc.), a style is automatically created at scene load-time with the naming scheme blend_base
, e.g. translucent_polygons
, overlay_lines
, etc. Each of these is a minimal style definition, such as (if expressed in YAML):translucent_polygons:
base: polygons
blend: translucent
parse_json
property:
parse_json
is true
, then each property will be checked to see if it "looks like" stringified JSON (defined as a string with first character being {
or [
); if so, it is parsed as JSON (with JSON.parse
).parse_json
is an array of property names, only those specific properties are checked for JSON parsing. This is preferred to the above, because it limits the parsing impact to only the fields that need it.parse_json
is undefined/null/false, no special parsing of properties is done (e.g. the current behavior).sources:
tiles:
type: MVT
url: https://...
parse_json: [prop_a, prop_b] # treat feature properties 'prop_a' and 'prop_b' as stringified JSON
filter
syntax for accessing nested feature properties #715
.
can be used to access nested feature properties (these properties could have been encoded in a GeoJSON/TopoJSON source, or parsed from MVT stringified JSON properties with the feature introduced above). Previously, these properties could only be accessed through custom JS filter
functions.a: { b: { c: 'test' } }
, this filter will match:
filter: { a.b.c: test }
.
can be escaped with \.
, e.g. a feature property named 'd.e.f': 'escaped'
will match with:
filter: { d\.e\.f: escaped }
{ 'a.b': { c: 'mixed' }
would match with:
filter: { a\.b.c: mixed }
filter
syntax for array-to-array operations #715
filter
syntax to support querying these fields more easily. Two keywords are added for this, extending the same filter object pattern we use for min/max
range filter syntax.includes_any
: check if an array a
contains one or more of the values p
, q
, r
:
filter: { a: { includes_any: [p, q, r] } }
includes_all
: check if an array a
contains the values p
, q
, AND r
:
filter: { a: { includes_all: [p, q, r] } }
all_layers: true
wildcard for data source layer matching #713
layer
in the data
block in layers
. When the parameter all_layers: true
is included, it will match ALL layers in the data source. This is useful for easily creating wireframe-like views, without knowing or needing to specify all the layers in the data source.Improvements
feature.id
#720
feature.id
property (at the top feature
level, outside feature.properties
; some data sets may separately include an id or similar property within feature.properties
), but we haven't had full support for it. This version fixes that.feature.id
persists wherever features are internally copied/synthesized/etc. internallyfeature.id
in user-authored JS scene functions with a new $id
variablefeature.id
in feature object results returned from scene.queryFeatures()
feature.id
in the default uniqueness check for scene.queryFeatures()
, with $id
syntax used if specifying a list of properties to uniqueify on (see #720 for details).repeat_distance
for point feature labels #718
repeat_distance
for labels has always been 256px
across the board. This is a sensible default for cases such as street labels (the original use case for repeat label culling) and road shields, but can generate unexpected results particularly when applied to point labels. For example, when labelling data with a property that has a finite set of values, such as category names ("bar", "restaurant", "hardware store", etc.) or numeric values, it's often surprising/undesirable that only a few labels are plotted.repeat_distance
is 0px
.repeat_distance
continues to be 256px
. Note that in these examples, the labels themselves may still be point labels -- it is the underlying geometry type that matters, e.g. road shields are point labels generated from line geometries.Bug Fixes
scene.queryFeatures()
7946554Performance/Internal
high-performance
for WebGL's powerPreference
setting. This will ask for use of the discrete GPU where possible. The user can override this default, as with other GL context options:const layer = Tangram.leafletLayer({ scene, { webGLContextOptions: { powerPreference: 'low-power' } } });
Improvements
kind_detail: [park, aerodrome, university]
) bcd6754Bug Fixes
u
coordinates f2b4957_
to reduce collisions with user-defined styles a3ab5d4Demo
scene
query paramImprovements
view_complete
events while scene is updating. 593c312 8bc21d5Bug Fixes
bounds
. b08f8c8queryFeatures()
to tiles that are loaded. fbb9e33New Features
priority
and exclusive
#705
priority
controls the order in which sub-layers at the same level are matched, and which one "wins" when multiple matching layers are merged.exclusive
ensures that the layer is mutually exclusive, and no other sub-layers at the same level will match.if/else if/else
filter patterns can be expressed with these new keywords, e.g.:
layers:
layerA: # if matches layerA...
filter: ...
priority: 1
exclusive: true
draw: ...
layerB: # else if matches layerB...
filter: ...
priority: 2
exclusive: true
draw: ...
zooms
parameter allows for control over which map view zoom levels load new tiles, with tiles overzoomed when viewing zooms in between. For example, to only load new tile data at every other zoom level:
sources:
tilezen:
type: MVT
url: ...
zooms: [0, 2, 4, 6, 8, 10, 12, 14, 16] # only load tiles every 2 zooms
zooms
and max_zoom
is present, the last zoom listed in zooms
takes precedence, and overrides the max_zoom
parameter. The min_display_zoom
also automatically defaults to the first entry in the zooms
list.blend_order
at the draw
group level #703
blend_order
to be set at the styles
level (which has led to an unwieldy pattern of several "template" styles that vary only by blend_order
), this change enables blend_order
to be set within a draw
group. This allows for much more flexible blend_order
expressions, and a semantic use that aligns with the order
parameter used for geometry world order of opaque
-rendered features. For example, for a style with overlay
blending:
layers:
overlays:
draw:
polygons-overlay:
blend_order: 3
...
{q}
token (as an alternative to the {x}
/{y}
/{z}
URL pattern). For example, a Microsoft aerial imagery raster layer:
sources:
msft-aerial:
type: Raster
url: https://ecn.t3.tiles.virtualearth.net/tiles/a{q}.jpeg?g=587
Improvements
opaque
features #704Bug Fixes
Bug Fixes
points
rendered with non-overlay
/inlay
blending.Improvements