nww04
nww04

Reputation: 1857

How to set marker Z-index on MapBox Android?

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?

Upvotes: 7

Views: 3682

Answers (3)

Jedi-Philosopher
Jedi-Philosopher

Reputation: 146

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).

Upvotes: 7

Ivan Yulin
Ivan Yulin

Reputation: 1046

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);

Upvotes: 1

alijandro
alijandro

Reputation: 12147

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.

Upvotes: 1

Related Questions