-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
How to differentiate between clicking on map and clicking on a marker? #1209
Comments
Currently not - supporting this kind of behavior is part of the previous ticket #656 |
Was this feature added? I could find examples where clicking on 'symbol' and 'cluster' worked but still unsure how to detect click on markers. |
+1 |
Any update on this? |
For those of you who get here wondering how on earth Mapbox GL JS (which seems to be awesome) could not implement a 'click' event like I was... turns out the solution is actually pretty nice and you just need to get the markers 'element' and listen to that click event e.g.
Cheers :) |
My concern about your solution is that it's going to apply one event handler for each marker and if there are lots of them the page might become too slow |
u just saved me from depression, love you man <3 <3 <3 |
|
My use case is different in that I want to know when the map is clicked and the click was not on a marker. Anybody have an idea on how to differentiate? |
for example, you could differentiate a click on a marker from a click on a map, check the property 'map.getCanvas().style.cursor'. If it's "pointer", then it's a marker |
I'd like to have a popup open when clicking on a marker (with info specific to that marker).
I see that the popup example displays a popup when clicking on the map.
How to differentiate between the two events "clicking on the map" and "clicking on a marker' ?
The text was updated successfully, but these errors were encountered: