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?
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).
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.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With