Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I'm using MapBox SDK for Android to display a geojson file on top of a map.
From geojson "features", I create some "fillLayer", each of them is associate to a value from properties object in geojson.
I fill each layer with a colour corresponding to the value.
To get this value from a specific localisation I use the API call:
"queryRenderedFeatures"
Here is how I create layer from previously created geojsonSource object:
for (int i=0; i < list_value_geojson.size(); i++){
Map.Entry<Integer, GeoJsonSource> entry = list_value_geojson.get(i);
mapboxMap.addSource(entry.getValue());
FillLayer fillLayer = new FillLayer(entry.getValue().getId(), entry.getValue().getId());
fillLayer.setProperties(PropertyFactory.fillColor(Color.parseColor(hashMapColors.get(entry.getKey()))));
mapboxMap.addLayer(fillLayer);
Here, how I use queryRenderedFeatures from a "Location" object:
final PointF pixel = my_mapboxMap.getProjection().toScreenLocation(new LatLng(location.getLatitude(), location.getLongitude()));
List<Feature> features = my_mapboxMap.queryRenderedFeatures(pixel);
My problem
queryRenderedFeatures function, sometime, return me too much Features, exemple: I search for a specific location and I get three features, but only the third one has the correct value, the two first have the value from the layer just next to.
Exemple
The good value is 174 not 181, colour should be dark bue.
Here is queryrenderedfeatures result:
0 = {Feature@6242} : {"value":181}
1 = {Feature@6243} : {"value":181}
2 = {Feature@6244} : {"value":174}
Question
How do I know which feature should I use?
MapBox "know" because the colour of the display layer is correct.
Thank you a lot for having read me.
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.