josxha / flutter-maplibre

Permissive and performant mapping library that supports Mapbox Vector Tiles (MVT) powered by MapLibre SDKs.
https://flutter-maplibre.pages.dev
Other
17 stars 3 forks source link

[FEATURE] Detect if a layer has been clicked #71

Closed josxha closed 1 month ago

josxha commented 1 month ago

Feature Description

There is currently no good way to detect if a marker, circle or item of an other layer has been received gesture input by the user.

Describe alternatives you've considered

We can already detect gesture inputs to the map in general and listen to the via the map events callback. It is currently not possible to check for the clicked layers with this.

Additional context

josxha commented 1 month ago

MapLibre GL JS and MapLibre Android both have a queryRenderedFeatures method but both return different results. ML Android only returns the GeoJSON Features while ML GL JS additioanlly returns the layer id and layer source id.

The MapLibre Android Annotations Plugin detects if a annotation layer has been clicked by checking every layer on it's own. If the returns Feature list is empty, the Annotation Layer has not been clicked, if it contains 1 item, it has been clicked.

https://github.com/maplibre/maplibre-plugins-android/blob/main/plugin-annotation/src/main/java/org/maplibre/android/plugins/annotation/AnnotationManager.java#L447-L454