'Flutter Mapbox clickable cluster annotations
I am trying to use Flutter mapbox_gl package to display clustered data, support for this functionnality has been added recently as showed in this example.
When the user zooms in, I would like to make symbols clickable, I have followed this example of clickable annotations but it seems not working, basically what I did is exactly combining the two examples: adding cluster layers (symbols and circles) using the map controller through onStyleLoadedCallback
property, then adding on-click callbacks in my onMapCreated
property (using onSymbolTapped
& onCircleTapped
methods). Am I doing something wrong?
Solution 1:[1]
For the clickable annotations from a source, as they come from a GeojsonSource, you must use onFeatureTapped
. This will give you 3 data : the id (defined in the source), the point (coordinate on the screen) and the latlng (position on the map).
This allows you to set a generic callback for both the features in the source and the clusters made with it.
The package currently does not support having more data returned in the callbacks.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Gautier Vuillaume |