diff --git a/src/source/geojson_source.js b/src/source/geojson_source.js index 2b043f1ef91..864c505873e 100644 --- a/src/source/geojson_source.js +++ b/src/source/geojson_source.js @@ -230,6 +230,22 @@ class GeoJSONSource extends Evented implements Source { * @param offset The number of features to skip (e.g. for pagination). * @param callback A callback to be called when the features are retrieved (`(error, features) => { ... }`). * @returns {GeoJSONSource} this + * @example + * // Retrieve cluster leaves on click + * map.on('click', 'clusters', function(e) { + * var features = map.queryRenderedFeatures(e.point, { + * layers: ['clusters'] + * }); + * + * var clusterId = features[0].properties.cluster_id; + * var pointCount = features[0].properties.point_count; + * var clusterSource = map.getSource('clusters'); + * + * clusterSource.getClusterLeaves(clusterId, pointCount, 0, (error, features) => { + * // Print cluster leaves in the console + * console.log('Cluster leaves:', error, features); + * }) + * }); */ getClusterLeaves(clusterId: number, limit: number, offset: number, callback: Callback>) { this.actor.send('geojson.getClusterLeaves', {