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
Returns
this
getClusterExpansionZoom(clusterId, callback): tt.GeoJSONSource
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
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