Skip to content

ClusteredMarker intercepts onPress on nearby individual markers #296

Description

@lucas-mahe-insideapp

Description

The ClusteredMarker component sets its zIndex to points + 1 (number of grouped markers + 1):

// lib/ClusteredMarker.js, line 25
<Marker style={{ zIndex: points + 1 }} ...>

Individual child <Marker> components that are not part of a cluster have no zIndex set (defaults to 0). As a result, even when a device pin is rendered visually beside a cluster bubble (not behind it), the cluster captures the tap first because its zIndex is higher.

On Android, the touch hit area of a <Marker> is larger than its visual bounds (known react-native-maps behavior), making this even worse — a cluster several pixels away from a marker can still steal the onPress.

Environment

  • react-native-map-clustering: 4.0.0
  • react-native-maps: 1.26.20
  • react-native: 0.82.1
  • Platform: Android (primary), iOS

Steps to Reproduce

  1. Render several custom <Marker> components near each other.
  2. Zoom to a level where some markers form a cluster and one or more remain unclustered nearby.
  3. Tap the unclustered individual marker.
  4. Observe: onClusterPress fires instead of the marker's onPress.

Expected Behavior

Tapping an individual marker that is visually distinct from a cluster should fire the marker's onPress, not the cluster's.

Actual Behavior

The cluster intercepts the tap because its zIndex (points + 1) is higher than the individual marker's default zIndex (0).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions