Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overlapping markers - on marker click - marker in the back is getting selected instead of the frontmost. #61

Closed
epiphany27 opened this issue Jun 22, 2017 · 7 comments
Labels

Comments

@epiphany27
Copy link

I have several markers close to each other on map, so much so that they sort of partially/fully overlap each other. I haven't specified any z-Index explicitly while adding the markers on the map, hence z-Index for all markers is 0.0 by default.

The problem is that when I tap on one of the overlapping markers which is at the frontmost position, the marker at the backmost is getting selected. So if there are 3 overlapping markers (say marker-1, marker-2, marker-3) one behind the other, marker-1 being at the front, marker-3 at the back and marker-2 is the middle of marker-1 & 2, when I click on marker-1, marker-3 gets selected instead. When I click again (on the same click point), marker-2 gets selected next, click again the third time, marker-1 gets selected finally.

At first, I thought there is probably a bug on my end or in the Google Maps library itself. After enough research online, I finally landed on google maps docs which doesn't quite answer my question.
From google-map API docs:- https://developers.google.com/maps/documentation/android-api/marker#marker_click_events

Clicking on a cluster of markers causes subsequent clicks to cycle through the cluster, selecting each in turn. The order of the cycle first prioritises z-index, then proximity to the click point.

(All marker's z-Indices are the same (0.0) in my case.)

On the other hand, when I checked on iOS (using iOS google maps library), I found the marker selection sequence to be correct (Marker-1 -> Marker-2 -> Marker-3) unlike Android which was the exact opposite.

Is this intended to be this way on Android? Or is it a Google Map library bug. Is there a way I could reverse the marker click sequence on Android like the way it's on iOS.

I know, one workaround could be to use marker clustering (ClusterManager etc) in such cases of overlapping markers, but I don't want to go that route for now.

Any comment will be highly appreciated.
Thanks.

@epiphany27 epiphany27 changed the title Overlapping markers - on marker click - marker in the back is getting selected instead of frontmost. Overlapping markers - on marker click - marker in the back is getting selected instead of the frontmost. Jun 22, 2017
@ApetrailJatinder
Copy link

same issue.Background marker get the click event not front one.

@developer--
Copy link

I had the same issue, any solution??????????????

@danielmockaitis
Copy link

Someone please 🚨

@maxcruz
Copy link

maxcruz commented May 29, 2019

I don't know if it's the best solution, but, my workaround is to set a high value in a variable as maxZIndex (the number of markers + 1 is fine), and then when I click on the marker:
previousMarker.zIndex = previousMarker.zIndex - 1
currentMarker.zIndex = maxZIndex + 1f
The current marker is then assigned to the previous to move it backward on the next click

@stale
Copy link

stale bot commented Oct 3, 2019

This issue has been automatically marked as stale because it has not had recent activity. Please comment here if it is still valid so that we can reprioritize. Thank you!

@stale stale bot added the stale label Oct 3, 2019
@stale
Copy link

stale bot commented Nov 2, 2019

Closing this. Please reopen if you believe it should be addressed. Thank you for your contribution.

@stale stale bot closed this as completed Nov 2, 2019
@shriharsha-bhagwat
Copy link

@epiphany27 Any solutions to this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants