Aiden Fry Aiden Fry - 1 year ago 140
Android Question

Google Maps v2 Marker zOrdering - Set to top

I know there are a few threads around on this topic but i havent yet found a good enough solution.

I NEED to place a marker over the top of all other markers. How do i do this?

I have tried adding this marker before and after all other markers, however the ordering seems to be from bottom (front) to top (back) on the map view. This is not acceptable as I want to center on a marker which is in front of all markers.

I know that Polygons can be zOrdered but I would MUCH prefer a nicely styled graphic!

In-fact you can't order a Polygon over a marker!

"The order in which this polygon is drawn with respect to other overlays, including Polylines, GroundOverlays and TileOverlays, but not Markers. An overlay with a larger z-index is drawn over overlays with smaller z-indices. The order of overlays with the same z-index value is arbitrary. The default is 0." -

Does anyone have any ideas on this?

Answer Source

Whilst not the perfect solution! I have figured out how to show a selected (tapped) marker over all other markers by consuming the onMarkerClick event. Returning TRUE will consume this event, so we have to do the showInfoWindow and zoom to center

    public boolean onMarkerClick(Marker marker) {

       //Manually open the window

       //Animate to center

       //Consume the method
       return true;