0

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. :-(

nasch
  • 5,330
  • 6
  • 31
  • 52

1 Answers1

4

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.

Tobrun
  • 18,291
  • 10
  • 66
  • 81
  • I actually got MapView working so I don't know if this works but maybe it will help someone else. – nasch Jul 25 '17 at 16:37
  • I can only advice you to use selectMarker as noted, this manages selection state correctly – Tobrun Jul 25 '17 at 16:41
  • 1
    see javadoc of Marker#showInfoWindow: Do not use this method, used internally by the SDK. Use {@link MapboxMap#selectMarker(Marker)} if you want to programmatically display the markers info window. – Tobrun Jul 25 '17 at 16:42
  • Seems problematic to have a method that isn't intended for use outside the library to be marked public. `selectMarker` does work though. – nasch Jul 25 '17 at 17:16