[Android] onMarkerClick calls showInfoWindow() on markers that have no info window, raising them above every zIndex

Author: isaacrowntreeCreated Sep 17, 2026Updated Sep 17, 2026

Summary

With moveOnMarkerPress={false}, MapView.onMarkerClick calls marker.showInfoWindow() for every tapped marker, including markers that have no info window at all (no title, no callout child). Google Maps draws the marker whose info window is showing above every other marker regardless of zIndex, and an empty info window still counts. So every tapped marker silently rises above everything else on the map, including markers with a higher zIndex, and stays there until another marker is tapped.

We found this because our selection highlight (a separate marker at zIndex 999999) rendered perfectly but underneath the tapped base pin. Reading the screen pixel at the pin's centre showed the base colour, not the highlight.

Reproducible sample code

typescript
<MapView moveOnMarkerPress={false}>
  <Marker coordinate={c} image={basePin} zIndex={1} />          {/* no title, no callout */}
  <Marker coordinate={c} image={highlightPin} zIndex={999999} />
</MapView>

Steps to reproduce

Tap the location. The zIndex 1 marker receives the click.

Expected result

The zIndex 999999 marker stays on top; nothing about a tap should reorder markers that have no info window.

Actual result

The tapped zIndex 1 marker is drawn above the zIndex 999999 one until a different marker is tapped.

Fix

diff
--- a/android/src/main/java/com/rnmaps/maps/MapView.java
+++ b/android/src/main/java/com/rnmaps/maps/MapView.java
@@ -592,7 +592,12 @@
                 if (view.moveOnMarkerPress) {
                     return false;
                 } else {
-                    marker.showInfoWindow();
+                    // Only show an info window the marker actually has: Google draws the
+                    // marker whose info window is showing above every other marker
+                    // regardless of zIndex, and an empty window still counts.
+                    String title = marker.getTitle();
+                    if (airMapMarker.getCalloutView() != null || (title != null && !title.isEmpty())) {
+                        marker.showInfoWindow();
+                    }
                     return true;
                 }

React Native Maps Version

1.29.0 (present on master, v1.29.2)

What platforms are you seeing the problem on?

Android

React Native Version

0.86 (Expo SDK 57), New Architecture

Device(s)

Samsung A13, arm64 emulator (API 36)

Additional information

Verified by an instrumented test that reads the screenshot pixel at the selected pin's centre before and after a real tap. A full write-up will be at https://zackdesign.biz/which-pin-did-you-tap/ shortly.

Source: react-native-maps/react-native-maps