Mapbox-gl-js: Click on cluster points to get all contained points properties

Created on 3 Jun 2016  路  6Comments  路  Source: mapbox/mapbox-gl-js

mapbox-gl-js version:0.18.0

Steps to Trigger Behavior

Hi
I am new to mapboxgl, I have a question about how I can get all points belong to a certain cluster point? based on the example, I am able to generate a cluster markers and when mouse click on cluster circle, using following code only be able to get total points. so it will be good to have a properties with a array of points in the resource.

var features = mapBox.queryRenderedFeatures(e.point, { layers: ['cluster'] });
if (!features.length) {
 return;
}               
var feature = features[0];
var totalNum = feature['point_count'];

Expected Behavior

I hope it can return value from geoJsonSource list this.

{
   cluster : 1,
   point_count : integer,
   point_count_abbreviated : integer,
   **points_properties : included points properties array,**
}

Or if there is another solution can solve my problem, it will be great

Thanks

Most helpful comment

All 6 comments

Looking for a similar _Expected Behavior_. I need those points to compute bounds that I will use to call fitBounds on my map object.

I think it will not be fixed anytime soon #2384.

This issue is a duplicate of https://github.com/mapbox/mapbox-gl-js/issues/2358. Sorry! This functionality would be nice but it is not practical.

I understand the way for store all those points in cluster point's properties is ambition. But I wonder is there another way to get those points by a method or calculation from the source. I can see the index process is using kdbush, but i don't know is it possible to generate those points again when click on a cluster point.

@barrylachapelle The results that print don't always reflect the count on the cluster. It would be nice if we could make this more accurate.

bump!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yoursweater picture yoursweater  路  3Comments

bgentry picture bgentry  路  3Comments

foundryspatial-duncan picture foundryspatial-duncan  路  3Comments

stevage picture stevage  路  3Comments

muesliq picture muesliq  路  3Comments