Bring Google Map Markers to Front by Changing Z-Index in Android
Tried @Simo's answer, but it doesn't seem to work on my phone (maybe changed with Lollipop?) - when showInfoWindow() sees that there is nothing to display it seems to skip bringing the pin to the front. I was able to fix this by using the following layout:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="0dp"
android:layout_height="0dp" >
<!-- Need a " " so that showing this isn't a no-op -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" "/>
</FrameLayout>
In latest release google map now have control over zIndex in Android. https://developers.google.com/maps/documentation/android-api/releases#june_27_2016
You can use this now:
mMap.addMarker(new MarkerOptions()
.position(mLatLng)
.title("" + name)
.snippet("" + pingDate)
.icon(BitmapDescriptorFactory.fromBitmap(icon))
.zIndex(yourZIndex));
From the documentation,
The z-index specifies the stack order of this marker, relative to other markers on the map. A marker with a high z-index is drawn on top of markers with lower z-indexes. The default z-index value is 0.