-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
feature req: Re-initialize layout on close/re-open #4
Comments
I'm also having issues with this. I would like to be able to pan, click a marker, and have the position of the popup update. |
I accomplished this by binding the popup on marker click, then destroying it and binding a new one when you click it again, therefore the coordinates are always fresh. |
I think I did the same -- will try to dig up a snippet to post. |
This is applied to a leaflet marker (note that "this" here is the marker itself:
|
I had a slightly different approach: marker.on('click', function (e) {
var clickedPopup = e.target.getPopup();
var newPopup = new L.Rrose({ offset: new L.Point(0, -10), closeButton: false, autoPan: false, closeOnClick: true });
var popupContent = yourPopupContentVariable;
//If a popup has not already been bound to the marker, create one and bind it.
if (!clickedPopup) {
newPopup.setContent(popupContent)
.setLatLng(e.latlng)
.openOn(e.target._map);
e.target.bindPopup(newPopup);
}
//We need to destroy and recreate the popup each time the marker is clicked to refresh its position
else if (!clickedPopup._isOpen) {
var content = clickedPopup.getContent();
e.target.unbindPopup(clickedPopup);
newPopup.setContent(content)
.setLatLng(e.latlng)
.openOn(e.target._map);
e.target.bindPopup(newPopup);
}
}); |
Neither of these methods help in my particular case. We bind the popup content to the marker when the page loads for all markers, this is due to our application fetching search results on load. We then have a simple:
and e.layer.closePopup() for when the user clicks out or on another marker. Hopefully there is a way to embed this in the L.Rrose extension method to occur when the openPopup() method occurs vs having to re-bind the popup on every close and re-open. |
@1parkplace why can't you use the method I did? You can use |
If the popup is closed, map is panned, and popup reopened,
then the orientation should be recalculated.
The undesirable behavior can be seen when using the "bindPopup" method on a marker.
The text was updated successfully, but these errors were encountered: