Search code examples
androidmapboxmapbox-marker

Customize Mapbox snippet information layout


I have been using Mapbox in a recent project of mine and I was just wondering if it is possible to customize the default marker information box.

Mapbox Information box

I was hoping there was a way use a custom xml layout so that I would be able to add other assets to the information box (Images, icons, etc). I have done a little bit of looking around but I cannot seem to see any references to this being done, is it something Mapbox supports?

I found this: https://www.mapbox.com/android-sdk/api/2.2.0/com/mapbox/mapboxsdk/views/MapView.InfoWindowAdapter.html

But how do I apply it?


Solution

  • First, you are using a really old version of our SDK, please update to either 4.1.1 or 4.2.0-beta.5 for better performance along with new features an abundance of bug fixes.

    You'll find this example useful for creating a custom info window.

    mapboxMap.setInfoWindowAdapter(new MapboxMap.InfoWindowAdapter() {
              @Nullable
              @Override
              public View getInfoWindow(@NonNull Marker marker) {
    
                // return your info window view. 
    
                return view
              }
    });