v0.4.0
New Features + Style Syntax/API Changes
- Multi-line labels: line wrapping of labels, controlled by
text_wrap
andalign
properties intext
-based styles. By default, wrapping is enabled for point labels, and disabled for line labels. See #205 for more info.- Wrapping
text_wrap: true
uses default wrapping (15 characters).text_wrap: 10
sets a maximum line length of 10 characters.text_wrap: false
disables wrapping.- Explicit line breaks (
\n
chars) will cause a line break (even iftext_wrap
is disabled).
- Alignment of text for multi-line labels can be controlled with
align
, with one of:center
(default)left
justifiedright
justified- Alignment has no effect for single-line labels.
- Wrapping
- Label anchors: point labels can be anchored relative to their point location. See #182 for more info.
anchor
can be set to:center
(default),top
,bottom
,left
,right
,top-left
,top-right
,bottom-left
,bottom-right
- Text alignment is also defaulted (if not explicitly set with
align
) to match the anchor type:anchor: center | top | bottom
=> defaultsalign: center
anchor: left | top-left | bottom-left
=> defaultsalign: right
anchor: right | top-right | bottom-right
=> defaultsalign: left
- JS-only option to move the label into the tile is now exposed as style property
move_into_tile
(defaultstrue
to match previous behavior, but should be set tofalse
if using anchor/align functionality for text + icon combinations, otherwise, text can get out of sync with expected position).
- Transparent backgrounds: adds alpha to the Tangram GL canvas, which allows for Leaflet layers (or other HTML content) to be placed beneath the map, in addition to on top of it. See #202 for more info. Examples:
- Default is transparent background, equivalent to:
scene: { background: { color: transparent } }
- To allow background to show through with 50% opacity:
scene: { background: { color: [0, 0, 0, .5] } }
- Default is transparent background, equivalent to:
- Shader position accessors:
vec4 modelPosition()
andvec4 worldPosition()
accessors should be used in lieu of directly accessing attributea_position
and varyingv_world_position
.modelPosition()
provides vertex position within its tile (model) space, where [0, 1] is the scale of the tile on x & y axes. Unclipped geometries can contain values outside [0, 1] range, as can z coordinates which have the same scale, e.g. a height of 1 corresponds to the length of the tile in x and y.worldPosition()
provides vertex position in world space (web mercator meters), with wrapping (configurable viaTANGRAM_WORLD_POSITION_WRAP
) applied to avoid float precision issues at higher zooms.- This change avoids styles that depend on implementation details (such as position packed as a short integer) which are subject to change and which diverge between JS and ES. The new accessors provided a common interface to these properties. See #197.
- Browserify/bundle compatibility: Tangram can be loaded outside of a bundled JS file. Due to lingering issues around web worker instantiation, Tangram still cannot (yet) be used as a a browserify module itself (except through
browserify-shim
), however dependencies such as Leaflet can now be bundled separately. See #208 for more info.
Breaking Changes
- Due to new GL canvas position in DOM (to support transparency), event listeners that were previously attached to
scene.container
should now be attached tomap.getContainer()
(wheremap
is the Leaflet map object). See the included demo here and here for an example. JS used for hover/click feature interactivity (for features markedinteractive
) are affected by this change and should be updated.
Bug Fixes
- Style mixing: support "diamond" mixin patterns for more complex style composition, e.g.:
- B mixes A
- C mixes A
- D mixes [B, C]
- D should end up with only one copy of A's shader blocks
- Shader uniform "inheritance": at run-time, style-specific uniforms will use the value explicitly defined for that style if present, otherwise will forward to the appropriate ancestor style from which it was mixed in. Allows uniform values to be changed at run-time and properly cascade one or more levels to descendant styles.
- Polygon extrusion: don't extrude polygon edges along tile boundaries by default. These were usually invisible due to being "interior walls" in buildings, but are not desirable and produce artifacts when alpha blending is used.
- Leaflet: fix ability for Leaflet scroll wheel zoom to be enabled/disabled at run-time.
- Style materials: fix support for texture objects embedded in material properties, e.g.
material: diffuse: texture: { url: ..., filtering: mipmap }
- Style mixing: fix mixing of
blend
,null
values would causeopaque
default to be used, instead of falling back on base style via prototype. - Textures: add URL cache buster for textures.
- Tile data: clear worker tile cache when data source config changes (sources with custom data transforms were not refreshing properly when config was updated).
- Leaflet: when tile build finishes, only update tile list via tile manager internally; calling scene update was interfering with Leaflet animations such as
flyTo()
. - Style layer rules: expose
$layer
property for JS filters/properties. - Feature selection: fix feature selection change flag (did not always register a change).
- Resolves all remaining known issues with "dirty" text halos.
Internal
- To support transparent backgrounds, the GL canvas is now inserted in the correct location in the Leaflet DOM (previously it was pulled out of the DOM to make positioning simpler, and because without alpha it often got covered by other layers).
- Clean up shaders by moving attribute unpacking into macros.
- Worker broker: remove neutered transferables from parent objects (these should not be accessed after transfer).
- Move Canvas text layout and rasterization to own file.
- Upgrade Babel (4.7.8 -> 5.8.29), and use runtime option (rather than polyfill) for both library and test builds.