Maps SDK for Web

tt.GeoJSONSource

A source containing GeoJSON. To see a full list of supported properties, please refer to Map Style Specification.


// add geojson source
map.addSource('my-geojson', {
    type: 'geojson',
    data: {
        "type": "Feature",
        "geometry": {
            "type": "Polygon",
            "coordinates": [
                [
                    [-10.0, -10.0],
                    [10.0, -10.0],
                    [10.0, 10.0],
                    [-10.0, -10.0]
                ]
            ]
        }
   }
});

// remove
map.removeSource('my-geojson');

Methods

getClusterChildren(clusterId, callback): tt.GeoJSONSource

For clustered sources, fetches the children of the given cluster on the next zoom level (as an array of GeoJSON features).

Parameters
Name Description
clusterId
Number
default:None
The value of the cluster's cluster_id property.
callback
Function
default:None
A callback to be called when the features are retrieved.
Returns

this

getClusterExpansionZoom(clusterId, callback): tt.GeoJSONSource

For clustered sources, fetches the zoom at which the given cluster expands.

Parameters
Name Description
clusterId
Number
default:None
The value of the cluster's cluster_id property.
callback
Function
default:None
A callback to be called when the zoom value is retrieved.
Returns

this

getClusterLeaves(clusterId, limit, callback): tt.GeoJSONSource

For clustered sources, fetches the original points that belong to the cluster (as an array of GeoJSON features).

Parameters
Name Description
clusterId
Number
default:None
The value of the cluster's cluster_id property.
limit
Number
default:None
The maximum number of features to return.
callback
Function
default:None
A callback to be called when the features are retrieved.
Returns

this

setData(data): tt.GeoJSONSource

Sets the GeoJSON data and re-renders the map.

Parameters
Name Description
data
Object
default:None
GeoJSON feature, feature collection or an URL to such object.
Returns

this