nitaliano / react-native-mapbox-gl

A Mapbox GL react native module for creating custom maps
Other
2.16k stars 697 forks source link

Get underlying Features of a Cluster Point #1436

Open Mojo90 opened 5 years ago

Mojo90 commented 5 years ago

What I want to get are the Features which are clustered within one cluster point. So I saw that Issue https://github.com/mapbox/react-native-mapbox-gl/issues/1268 but I could not achieve it and I don't know how the best and simplest way is to achieve that. Please support. An example what I tried is:

In the onPress of ShapeSource:

onPress={(e) => {
  this.map.queryRenderedFeaturesAtPoint(e.nativeEvent.payload.geometry.coordinates).then(function(result){
                console.dir(result);
              });
}}

But the result is not what I was guessing it is: https://www.dropbox.com/s/hqk97xb2yg9oodf/Screenshot%202018-11-25%2011.21.35.png?dl=0

Can you please point me out how to easily get e.g. 2 points which are clustered in one point? I also had a look at supercluster but I did not found there a starting point. I just found that supercluster is implemented in react-native-mapbox-gl.


Off topic: My opinion is in general the documentation is very sparse and hard to find what you need. I think it should not be the claim of a company like Mapbox that users need to search closed/old issues how to implement something.

Btw: in the docs it states that queryRenderedFeaturesAtPoint returns an array, but that is not true it returns a promise which returns an array.