node package manager
Easy collaboration. Discover, share, and reuse code in your team. Create a free org »

mapbox-gl-datascope

js-standard-style

Scope your vector tile data.

Install

npm install mapbox-gl-datascope

Usage

mapboxgl.datascope(map, {
  layers: layers,
  properties: { 'road_density': 'Road Density (km/km2)' },
  popup: new mapboxgl.Popup({ closeButton: false }).addTo(map)
})

See also example.html.

API

datascope

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 } where format 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, default 0)
    • options.filter Array= Optional feature filter.

Returns DOMNode DOM node that is kept updated with rendered property data.