1

I have multiple markers on a map. Some of them overlap.

Is it possible to bring a certain marker to the front?

Danilo Bargen
  • 18,626
  • 15
  • 91
  • 127

1 Answers1

1

Yes. Starting with Mapbox Android SDK v4.1, the selected marker will come to front.

You can select a marker with mapboxMap.selectMarker(marker);.

zugaldia
  • 702
  • 3
  • 8
  • Thanks for the quick answer. The problem is that I'm providing my own `onMarkerClick` listener. If I call `selectMarker` inside that listener, I get infinite recursion (because `selectMarker` will call `onMarkerClick` again). Furthermore, even though I'm using the SDK 4.1, if I look at the source code behind `selectMarker`, I can't see any code that would change the order of the markers on the map. Maybe it's in the code that would show the info window? (I'm not using the default info bubble.) – Danilo Bargen Jul 02 '16 at 09:41
  • 1
    I haven't tried this but could you have some variable inside your `onMarkerClick` method to track the selected status of the marker to avoid the infinite loop? Also, the PR that brought this functionality is actually pretty simple and you can see it [here](https://github.com/mapbox/mapbox-gl-native/pull/5294). General z-index ordering isn't still supported but the work is tracked in this [ticket](https://github.com/mapbox/mapbox-gl-native/issues/5238). – zugaldia Jul 02 '16 at 16:27
  • 2
    This Android API mabox really sucks, you have to hack so much just to get the basic going. WTF are they smoking up there? – Neon Warge Jan 10 '17 at 09:16