Search code examples
androidmapboxmapbox-android

MapBox: show marker's info window without access to a MapView


I'm using the Android MapBox SDK, and I want to show the info window for a marker that I've created. showInfoWindow as far as I can tell is the only way to do this. The problem is it requires both a MapBoxMap, which I have, and a MapView, which I do not. I'm using MapFragment, and I don't see any way to get a MapView instance. It looks to me like this is a gap in the SDK but I'm hoping someone has a solution.

I already hit another critical problem preventing me from using a MapView (issue raised with MapBox) and now this is critical functionality for my app that I can't do without a MapView so I'm thinking I may have to abandon MapBox altogether. :-(


Solution

  • Instead of Marker.showInfoWindow you need to select the marker through:

    mapboxMap.selectMarker(Marker marker)

    This will not only show the InfoWindow but will also manage the selected state.