Responsible for invoking WorkerSource's geojson.loadData target, which handles loading the geojson data and preparing to serve it up as tiles, using geojson-vt or supercluster as appropriate.
Optional
diff: GeoJSONSourceDiffthe diff object
For clustered sources, fetches the children of the given cluster on the next zoom level (as an array of GeoJSON features).
The value of the cluster's cluster_id
property.
a promise that is resolved when the features are retrieved
For clustered sources, fetches the original points that belong to the cluster (as an array of GeoJSON features).
The value of the cluster's cluster_id
property.
The maximum number of features to return.
The number of features to skip (e.g. for pagination).
a promise that is resolved when the features are retrieved
Retrieve cluster leaves on click
map.on('click', 'clusters', (e) => {
let features = map.queryRenderedFeatures(e.point, {
layers: ['clusters']
});
let clusterId = features[0].properties.cluster_id;
let pointCount = features[0].properties.point_count;
let clusterSource = map.getSource('clusters');
const features = await clusterSource.getClusterLeaves(clusterId, pointCount);
// Print cluster leaves in the console
console.log('Cluster leaves:', features);
});
Removes a previously registered event listener.
The event type to remove listeners for.
The listener function to remove.
Adds a listener to a specified event type.
The event type to add a listen for.
The function to be called when the event is fired.
The listener function is called with the data object passed to fire
,
extended with target
and type
properties.
Adds a listener that will be called only once to a specified event type.
The listener will be called first time the event fires after the listener is registered.
The event type to listen for.
Optional
listener: ListenerThe function to be called when the event is fired the first time.
this
or a promise if a listener is not provided
To disable/enable clustering on the source options
The options to set
map.getSource('some id').setClusterOptions({cluster: false});
map.getSource('some id').setClusterOptions({cluster: false, clusterRadius: 50, clusterMaxZoom: 14});
Bubble all events fired by this instance of Evented to this parent instance of Evented.
Optional
parent: EventedOptional
data: anyUpdates the source's GeoJSON, and re-renders the map.
For sources with lots of features, this method can be used to make updates more quickly.
This approach requires unique IDs for every feature in the source. The IDs can either be specified on the feature, or by using the promoteId option to specify which property should be used as the ID.
It is an error to call updateData on a source that did not have unique IDs for each of its features already.
Updates are applied on a best-effort basis, updating an ID that does not exist will not result in an error.
The changes that need to be applied.
A source containing GeoJSON. (See the Style Specification for detailed documentation of options.)
Example
Example
Example
See