Releases: tangrams/tangram
Releases · tangrams/tangram
v0.13.2
Bug Fixes
- Add null checks on camera and view to prevent exceptions during initialization in some cases.
- Restore application of
color
andfilter
shader blocks to standalonetext
styles (as expected, these blocks are still not applied totext
attached to apoints
style). - Fix array iteration when applying
globals
, prevents worker data clone exceptions when Tangram is used alongside another library that modifies the underlying array prototype (such as Ember).
Internal
- Only mark scene as animating when
animated
styles are currently in view; improves idle performance for scenes with animated styles only used at some zooms or areas.
v0.13.1
Mostly internal refactoring to provide more flexibility and better performance on platforms such as iOS Mobile Safari that are sensitive to main thread/UI locking.
Bug Fixes
- Fix a few cases where labels would render incorrectly due to improper placement in the Canvas text atlas.
- Skip boundary labels if neither a left nor a right value was found. Fixes issue where some tiles wouldn't render; collision detection would never resolve for a given style/tile combination consisting of only empty boundary labels.
Internal
- Use 512px tiles for non-tiled data sources, for better label placement (fewer tile boundaries).
- Refactor Canvas text atlas creation for labels, to allow a single tile to place labels across multiple textures, with a maximum texture size per atlas of 2048x2048 pixels; the max texture size was chosen as a balance between minimizing the number of textures created, and the time needed to instantiate a GL texture from a Canvas element, which can cause a significant main thread lock on some platforms.
- Add "background task" model, to allow some long-running processes on the main thread (such as Canvas text label rendering) to be time-sliced across multiple animation frames; this ameliorates thread and UI locking when these processes take several frames (e.g. hundreds of milliseconds or more) to complete. Background tasks can be paused when individual tasks (or all tasks collectively) surpass a certain time threshold per frame, or when the user is interacting with the map.
- A given rendering style can now have multiple mesh "variants", which can vary by rendering state such as uniform values; this is used to vary the label atlas texture sampler when a given tile/style combination has more than one label texture.
- Remove optional stringification of worker message payloads, due to inconclusive benefit on current browser generations.
- Upgrade browserify.
v0.13.0
New Functionality
- Support for 512px sized tiles #548
- While web map tiles are traditionally displayed at a size of 256px (logical pixels) each, some tile services now provide tiles with a larger intended display size, such as 512px. This reduces the total number of tiles that need to be requested for any given view (since each tile covers more screen area).
- A tile size of 512px will fetch tiles that are one zoom level lower than the current view zoom. For example, if the view is at z16, then the corresponding z15 tile coordinates for that area will be fetched, and each will cover the 512x512 area traditionally occupied by four separate 256x256 tiles. This scheme ensures that, regardless of the display tile size being used, any given web map tile XYZ coordinate will correspond to the same geographical extent.
- Tangram data sources can enable larger tile sizes with the
tile_size
parameter, e.g.
sources: mapzen: type: ... url: ... tile_size: 512
tile_size
must be a power of 2 greater than or equal to 256 (and should not include any units such aspx
suffix)
- Ability to query features from tile data #566
- A new
Scene.queryFeatures()
method allows for directly querying tile data, with options to filter by feature properties and scene visibility, and group results by parameters or specify criteria for uniqueness. Matching features are returned with their properties, and optionally with their geometry when requested. - Tiles that intersect the current viewport are queried. Therefore the results will include the visible area, but may include nearby features as well.
- Query results are returned as a promise that resolves with an array of matching features.
- An optional
filter
object can be provided, using the same syntax used for selecting features for styling inlayers
. If nofilter
is provided, all features will be returned (subject to other parameters defined below). - Example:
scene.queryFeatures({ filter: { $layer: 'pois', kind: 'restaurant' } })
will return all restaurants in thepois
layer. - See #566 for further details on
filter
,visible
,group_by
,unique
, andgeometry
options. - This functionality is separate from the existing
Scene.getFeatureAt()
method, which returns a single feature at a given pixel location.
- A new
- Optional pixel radius parameter for the
Scene.getFeatureAt()
method #571- Previously,
Scene.getFeatureAt()
only returned a feature that was present at the exact pixel location provided. There are cases where a larger radius is useful, such as mobile devices where input is not as precise, or features rendered with thin lines that may be difficult to select. - The following methods can now specify radius:
- Direct scene interface:
scene.getFeatureAt(pixel, { radius })
- Leaflet layer interface for setting selection handlers:
layer.setSelectionEvents (events, { radius })
- Leaflet layer instantiation:
layer = Tangram.leafletLayer({ scene: 'path/to/scene.yaml', events: { click: clickHandler, }, selectionRadius: 10 };
- Direct scene interface:
radius
orselectionRadius
is an optional value in pixels (the default matches existing behavior, where radius is zero). When using a radius, the feature closest to the center point will be returned. As with existing feature selection, only features marked asinteractive: true
will register.- This feature also provides parity with Tangram ES.
- Previously,
- Optional background color parameter for screenshots #570
- Adds an optional background color that will be blended with any translucent pixels in the scene when capturing a screenshot. In normal browser presentation, these pixels are blended with whatever HTML content is behind them. With this optional parameter, users have more control to achieve similar results when capturing a screenshot.
- The default
background
color value iswhite
, as this is most likely to match default browser display (white Canvas background). Background can be set to any other color value accepted by Tangram (e.g.red
,[0.5, 0.5, 0]
), includingtransparent
, which would preserve a transparent background from Tangram. - Example of capturing screenshot and opening in window:
scene.screenshot({ background: 'transparent' }).then(s => window.open(s.url))
- Curved labels for Arabic #564
- Thanks to additional work by @mapmeld, curved labels now also support Arabic text. Tangram JS now supports curved labels for all text except for: bidirectional text (mixed explicit LTR and RTL characters -- neutral characters like punctuation or numbers are OK), and Mongolian script (these will still render, just as straight line labels).
- File type option for loading zip files from local blob #572
- Previously, the scene URL had to end in '.zip' when loading zipped scene files. To support cases where zipped files may be loaded locally, such as from a blob URL (see #565), a new file type option is provided.
file_type
when usingScene.load()
:scene.load(zip_blob_url, { file_type: 'zip' });
sceneFileType
when usingTangram.leafletLayer
:layer = Tangram.leafletLayer({ scene: zip_blob_url, sceneFileType: 'zip', ... });
Bug Fixes
- Fix override of array values (such as for zoom-based stops) when using default
draw
parameters for astyle
#568 - Handle over-zooming of raster tiles when wrapping around dateline f36098d
- Exclude any non-texture-specific props when comparing texture definitions (fixes reference count / flicker bug with over-zoomed raster tiles) 70a7bd7
- Don't count over-zoomed tiles against max proxy depth b9afe9d
- Shallow copy when loading a scene directly from a JS object, to allow a single scene config object to be loaded multiple times (may need to address modification of nested properties in the future) c0442b9
- Copy colors to avoid modifying the underlying object (fixes a case where a
global
color value used for multiple substitutions was being converted to a 4-element RGBA array, while some substitutions still expected the original 3-element RGB value) 1ef7a8c - Don't use scene clear color for selection buffer (could manifest as incorrect feature selection results, though this has not been observed) 68d4832
Internal
scene.config_path
is renamed to the more intuitivescene.base_path
. The existingscene.config_path
accessor will be maintained for now, but eventually deprecated.- Options to
scene.load()
should be passed as an object, e.g.:scene.load(scene_url, { base_path: 'https://site.com/scene/resources/' });
- The previous public documented API only had a single second argument, which was used for base path -- this is still backwards compatible but should be discouraged. Documentation will be updated.
- Simplification and caching of some RTL text handling.
v0.12.5
Improvements
- Support curved labels in several additional languages #555
- Adds curved label support for Burmese, Bengali, Devanagari, Khmer, Gujarati, Gurmukhi, Kannada, Lao, Malayalam, Oriya, Sinhala, Tamil, Thai, Tai Tham, Telugu, and Tibetan
- Use grapheme clusters (instead of characters) to find appropriate visual breakpoints
- Thanks to @mapmeld for the contribution and language expertise!
- Allow
introspection
flag to be passed as an option toTangram.leafletLayer
a347632- e.g.
Tangram.leafletLayer({ scene: 'scene.yaml', introspection: true })
will load the scene with introspection enabled, making a call toscene.setIntrospection(true)
unnecessary
- e.g.
Bug Fixes
- Fix bug where a style's default
draw
parameters could not be overridden a8011a1 - Fix additional right-to-left text issues (mis-classification of neutral characters as RTL)
- Fix incorrect colors in screenshots capture in Firefox #551
- Avoid the need for a custom UglifyJS plugin when bundling Tangram with Webpack
#559 f9e4cef - Suppress source map URL from minified build (prevent console warnings when source map not found)
Internal
- Don't request tiles for a data source if no top-level
layers
are enabled for it (saves networks requests) #560 - Cache text segmentation for improved label performance
v0.12.4
Bug Fixes
- Fix right-to-left text handling of neutral characters (e.g. punctuation) in multi-line (text wrapping) labels, and additional case for curved labels #541
- Fix missing spaces in curved labels with text wrapping enabled
- N.B.: curved labels currently do not support text wrapping; however, enabling the
text_wrap
parameter should not interfere with rendering of curved labels (this fixes a bug where the spaces in these labels were disappearing)
- N.B.: curved labels currently do not support text wrapping; however, enabling the
Functionality Changes
- Apply scene normalization, such as expanding paths relative to the scene's base URL, when the scene config is updated at run-time with
scene.updateConfig()
Internal
- Minor optimizations
v0.12.3
Bug Fixes
- Feature selection: only reset appropriate sources on partial rebuild
- Fixes issue where
scene.setDataSource()
would clear selection for all data sources, incorrectly removing some feature interactivity #552
- Fixes issue where
- Encapsulate point shader code to prevent namespace collisions with user-defined shader blocks f41813a
Internal
- Optimize GL VBO build process by dynamically compiling JS-to-typed-array function per unique vertex layout
- Improve error/log info for style compilation errors
v0.12.2
Bug Fixes
- Fix inconsistent
offset
direction for non-boundary labels #542 #545 - Fix inaccurate centroid calculation on small polygons #550
- Fix handling of neutral characters (e.g. punctuation, etc.) in RTL-text curved labels #541 #543
- N.B.: work on-going to fix similar issue w/multi-line labels
- Fix loading of raster tiles on Edge/IE #538
Functionality Changes
- Consistent label direction for near-vertical lines #517 #532
- Do not apply shader blocks on
points
-based styles to attachedtext
labels #549- Note: this provides compatibility with Tangram ES behavior; this change may affect the appearance of text in existing styles, however, this specific style combination is rare and text will continue to display.
- Add debug option to collect per-layer stats #544
- Allow Tangram debug settings to be passed in when creating Leaflet layer d911d42
- e.g.
layer = Tangram.leafletLayer({ scene: path/to/scene.yaml, debug: { layer_stats: true } });
- e.g.
v0.12.1
New Features
- WebGL context options can now be passed when creating the Tangram Leaflet layer #526
- For advanced use cases where the user may want to override Tangram's WebGL defaults, or directly access the Tangram Canvas. Example:
layer = Tangram.leafletLayer({ scene: ..., webGLContextOptions: { // explicitly add/override WebGL context options preserveDrawingBuffer: true, antialias: false } });
Bug Fixes
- Fix handling of Leaflet
minZoom
andnoWrap
options #529
Internal
- Prune layer and text caches to improve memory usage.
- Parse sublayers progressively (as the parent layer first matches a feature) to improve startup / tile build time.
- Improve memory usage for textures by not keeping reference to source data.
- Small improvements to text calculation by skipping unnecessary Canvas
measureText()
calls. - Adjust build process for source maps, so live-reload source map doesn't conflict with official build.
v0.12.0
Enhancements & Syntax Changes
- Library can be bundled as a JavaScript UMD module #488 #252
- Constraints that prevented the Tangram library from being bundleable using popular JS bundling tools such as browserify, webpack, or vanilla file concatenation have been removed. You can now
require()
orimport
Tangram. This also removes the requirement to serve the Tangram library under a specific filename.
- Constraints that prevented the Tangram library from being bundleable using popular JS bundling tools such as browserify, webpack, or vanilla file concatenation have been removed. You can now
- Curved labels #484
- Explicit left and right-side line labels #516
- The
text_source
parameter has been expanded to optionally accept a mapping with separateleft
andright
values. Each of these values is evaluated as a singletext_source
value is (as a string, array, or JS function). Example:
draw: text: ... text_source: left: 'name:left' # feature property name for left-side labels right: 'name:right' # feature property name for right-side labels
- Separate left and right-side labels are then placed along the line, with each label automatically offset by the height of the text. An additional
offset
can be optionally applied, with the Y value pushing each label in an opposite direction, away from the line. - This syntax is useful for dual-sided administrative boundary labels in a single feature, such as those provided by Mapzen's vector tile service:
- The
- Point outlines #472 #508
- Styling parameters have been added to allow for outlines drawn on
points
-based styles. A newoutline
block can be provided within thedraw
block, withcolor
andwidth
parameters (similar to outlines on thelines
style). - For example, to draw a 10px red dot, with a 2px white border:
draw: points: color: red size: 10px outline: color: white width: 2px
- Both the
width
andcolor
parameters in theoutline
block can also be JS functions, for example to set outline width by building height:width: function() { return feature.height/50; }
- Point outlines are ignored if a
points
-based style has a texture/sprite set. - Example of points representing buildings, dynamically sized with JS function based on building height:
- Styling parameters have been added to allow for outlines drawn on
- Style definitions can specify default
draw
parameters #504 #489- Enables a rendering style to include defaults for
draw
parameters. Any parameters specified in a optionaldraw
block under the style's definition (withinstyles
) will be automatically copied whenever that style is drawn (using a layerdraw
block underlayers
). - These defaults can be overridden or supplemented as usual by
draw
blocks withinlayers
. - An example, setting a default
size
for anicons
style:
styles: # setting up style with default draw size icons: base: points texture: icons draw: size: 16px # default size layers: ... draw: # drawing style with default size, plus setting sprite icons: sprite: coffee
- Enables a rendering style to include defaults for
- Data sources can specify optional subdomain list #445 #525
- New
{s}
andurl_subdomains
parameters can be used together to distribute tile requests across multiple subdomains:
sources: source-name: type: MVT url: https://{s}.some-tile-server.com/{z}/{y}/{x}.mvt url_subdomains: [a, b, c]
- This example would cause the following hosts to be used for tile requests:
https://a.some-tile-server.com/{z}/{y}/{x}.mvt
https://b.some-tile-server.com/{z}/{y}/{x}.mvt
https://c.some-tile-server.com/{z}/{y}/{x}.mvt
- New
- Layer-level
visible
parameter changed toenabled
#523 tangrams/tangram-docs#198- This parameter has been renamed to
enabled
to prevent confusion with the separatedraw
group-levelvisible
property, which continues to exist as-is. These two parameters appear close to one another within thelayers
hierarchy and were often mixed up. - Backwards compatibility is provided for the previous
visible
property name: if theenabled
parameter is undefined for a given layer, any value forvisible
will be used instead. However, layer-levelvisible
will be deprecated in a future release. - Tangram JS's treatment of the layer
enabled
(neevisible
) parameter is also updated to match that of Tangram ES: once set by a layer, the parameter cannot be overridden by any descendant layers. This is useful for culling large portions of the layer tree, e.g. for layer-toggle controls and/or overlays. Thedraw
group-levelvisible
property continues to provide more fine-grained control with inheritance, where needed.
- This parameter has been renamed to
- Warn when a data source specifies parameter names in
url_params
that already exist in theurl
query string #515 - Improve rendering of shader-drawn
points
(e.g. those not using a texture/sprite)- Antialiased shader
- Don't snap to the pixel grid #481
Bug Fixes
- Features without an
order
parameter will not be drawn (unless theblend
mode is set tooverlay
). A warning will be logged #503- This is to provide consistent rendering behavior and to bring Tangram JS into parity with Tangram ES; some small style adjustments may be needed.
- Lookup global property names recursively, so globals can reference other globals fe6ff61
- Point widths have been fixed on high pixel density displays #492
- Fix miter limit fallback to bevel join 5addb37
- Handle GeoJSON features with a
null
geometry
field in non-tiled data sources (includes upgradinggeojson-vt
). - Convert
null
draw
groups into empty objects so they don't overwrite those higher in the layer tree during merging. - Handle race conditions where tiles are canceled mid-build.
- Warn on initial
null
values for uniforms in a style definition, and skip shader injection.
Deprecated