Hello,
I'm using version 1.0.3
You can't set the boundary and use an animation at the same time, like this:
This.map.flyToBounds (myBounds)
This.map.setMaxBounds (myBounds)
Exemple : http://playground-leaflet.rhcloud.com/yeya/1/edit
One solution is by adding "moveend" listener who will launch setMaxBounds once the animation finishes, but it's complicated and we must filter events.
Why not add a "end of the animation" callback function in parameters ?
It doesn't look like the linked example provides any useful information, am I missing something?
You could add a one-time moveend listener specifically for your flyTo animation:
map.flyToBounds(bounds);
map.once('moveend', function() {
map.setMaxBounds(bounds);
});
I think you aremissing somthing, look at the javascript tab.
Thanks for "once", it work.
There is a problem.
If the move of the map is automatic, by "flyTo" method and if we stop via a drag with mouse, event is not called.
Ok, could you provide an illustration of the issue?
I modified your previous example with a once('moveend'), and it works as I would expect if I pan the map in the middle of the fly to: the map's max bounds are correctly set and the map is locked around Paris: http://playground-leaflet.rhcloud.com/xih/edit?html,js,output
Ok, I've updated the example.
Now at the end of the movement, a marker is added to the center of Paris.
http://playground-leaflet.rhcloud.com/xiwi/1/edit?html,js,output
In some cases, when moving is stopped, the marker appears a little later (probably corresponding to the end of automatic movement).
In the other, it does not appear at all.
It appear if new moving on of the map.
I was able to reproduce this problem by just clicking (not dragging) the map while the flyTo animation was running.
My guess is that the click aborts the animation since the user begins a pan operation, but since the map is actually never dragged, no moveEnd event is fired. I would consider this a bug, so we will have to investigate further.
Ok,
Good news.
I repeat, sometimes the event is still launched.
Test clicking at the end of the movement to stop the map.
Most helpful comment
It doesn't look like the linked example provides any useful information, am I missing something?
You could add a one-time
moveendlistener specifically for yourflyToanimation: