Search code examples
javaandroidmapboxmapbox-androidmapbox-marker

Android MapBox - What is the best way to add markers with info window?


As mapbox.addMarker() is depracated I am wondering what is the best way to add marker with simple info window that is associated with the instance of the object and has click listener? I tried to use the code from Mapbox documentation: https://docs.mapbox.com/android/maps/examples/symbol-layer-info-window/

But it seems a bit too complicated though.. Is this the only way to add markers with info window?

Does anyone has any idea or link to example other than the one above?


Solution

  • The preferred way to add annotations to the map in Android is to use the Annotation Plugin:

    https://docs.mapbox.com/android/plugins/guides/annotation/

    I would recommend to take a look at this example:

    https://docs.mapbox.com/android/plugins/examples/marker-view-plugin/

    To get the same experience as in the example you have provided, you would have to add a click listener similar to how it is done in this example and only set the visibility of the customView that represents the text box when the symbol has been clicked.