Search code examples
javaandroidmapboxmapbox-android

Android Mapbox with clustering I want each feature to have different marker image


We are implementing clustering on my app. Until now we were using the addMarker method to add the markers, but now with clustering it seems that we should add them by using addSource.GeoJsonSource which we give a feature collection with all the points. With this new implementation, we are having problem giving different markers different images. We would appreciate if somebody could help.


Solution

  • The solution to this is not necessarily to add a new source.

    You can associate multiple images with a style and use a styling expression to determine which clusters use which images. As is done in this example: https://docs.mapbox.com/android/maps/examples/symbol-layer-clustering/


    ⚠️ Disclaimer: I currently work at Mapbox ⚠️