-
Notifications
You must be signed in to change notification settings - Fork 996
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
unbindPopup appears to clear click event listener #455
Comments
I created this fiddle to demonstrate:
It is entirely possible I am doing something incorrectly, but to see the issue simply run and click on the marker to see the popup, click off of the popup to make it go away, then click on the marker again and you will see the popup doesn't appear again. |
I try fix it. |
Were you able to fix this? |
I have not found a solution at this moment. I will be work on this issue at weekend. |
Great, let me know and I can test it. Thanks! |
Maybe I don't understand your problem, but if remove "popupclose" handler it works for me. |
Yes, I understand that not unbinding the popup allows the popup to continue to open, that is pretty much what I say at the end of the third from last paragraph in the original description. The issue is, I don't want to bind a popup to every marker. I was trying to be efficient and only bind a popup to a marker when it was clicked and then unbind the popup from the marker when the popup is closed. My fiddle demonstrates that this isn't possible since I no longer get click events for that marker after unbinding the popup in the close handler. |
I will close this issue here, since I was about to recreate my issue on using just a FeatureGroup, so I think this should be tracked on my original issue in Leaflet core. |
This issue is a copy of the following Leaflet issue:
It is not clear if this issue is in Leaflet or markercluster...
I am using Leaflet marker cluster since I'm dealing with lots of data. I do something like this to listen for clicks on markers:
And something like this to listen for popup close events:
To avoid creating excessive popups, I am trying to dynamically bind/unbind popups to the markers, like this:
This works the initial time a marker is clicked, but subsequent clicks on the marker do not trigger the event and thus the popup is not displayed. This only affects the clicked marker, but any time I click another marker and dismiss its popup, then it will no longer receive click events as well. If I do not unbind in the close event, but instead just close the popup then I continue to receive click events and my popup is displayed.
From my poking around, it appears that invoking unbindPopup() in this scenario is the equivalent to doing an "off click" for that specific marker. Perhaps I am missing something, but this doesn't really seem to be an intuitive behavior. I am simply trying to reduce memory consumption by disposing of unwanted popups.
Perhaps I am missing the more obvious way to do this, but I couldn't find anything.
The text was updated successfully, but these errors were encountered: