Scope your vector tile data.
npm install mapbox-gl-datascope
mapboxgl.datascope(map, {
layers: layers,
properties: { 'road_density': 'Road Density (km/km2)' },
popup: new mapboxgl.Popup({ closeButton: false }).addTo(map)
})
See also example.html.
Scope your data
Parameters
-
map
Map Mapbox GL map instance -
options
object-
options.layers
Array.<string> List of layers to query for data. -
options.properties
object Object mapping feature property keys to { name, format } whereformat
is an optional format function for the property value. Only these properties will be shown. -
options.summaries
object= Object mapping property keys to aggregation function name from geojson-polygon-aggregate or 'reducer' function(accumulator, clippedFeature) -> accumulator
-
options.popup
Popup= A mapbox-gl-js Popup control; if supplied, the popup will be populated with the rendered property data. -
options.event
string= Mouse event to use (mousemove, click) (optional, default'mousemove'
) -
options.radius
number= Feature query radius (optional, default0
) -
options.filter
Array= Optional feature filter.
-
Returns DOMNode DOM node that is kept updated with rendered property data.