7

My app shows a user marker. Basically, the user marker shows where the current user is on the map but I also have other markers placed on the map. In the end, it covers up my user marker. I want my User Marker to be on the top of the map. I want it to be rendered last so it shows on the very top.

Any idea?

Neon Warge
  • 1,817
  • 6
  • 29
  • 53
  • do you find the solution for your problem? – Linh Jul 03 '17 at 06:10
  • 1
    @PhanVanLinh, unfortunately no. There is no way to control this unless otherwise you implement your own Marker which is possible via ViewMarkerOptions which implements a view I think, there are other cool options there like anchor, offset, etc. Can't remember if it has z-ordering. Can't believe this basic stuff in 2D rendering was left out which is a shame really. I can't go down ViewMarkerOptions though, the map becomes so slow if you have hundreds of them. I think the best option would be the Mapbox Studio, I haven't tried it though. – Neon Warge Jul 04 '17 at 01:01

3 Answers3

5

In case anyone is looking for a newer answer for latest SDKs.

Mapbox Marker class is now deprecated in newer versions of Mapbox Android SDK. Annotations plugin is suggested instead, which has a Symbol class for markers.

In mapbox-android-plugin-annotation-v7 library Symbol class had a withZIndex() method which allowed to manipulate Z-ordering of map objects.

In mapbox-android-plugin-annotation-v8 this method was renamed to withSymbolSortKey() (which was a bit tricky to find and discover).

1

There is a solution from here https://github.com/mapbox/mapbox-gl-native/pull/5294

If you use MarkerView, you can bring your marker to the very top with MarkerViewManager#select call.

mapboxMap.getMarkerViewManager().select(marker);

It will end by calling View#bringToFront from Android View API, the selected marker view will show on top of all other marker views.

alijandro
  • 11,627
  • 2
  • 58
  • 74
1

I think this may help:

Mapbox Android SDK: Bring marker to front

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

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

Ivan Yulin
  • 794
  • 7
  • 15