Reset zoom and center don't work together after a map navigation (zoom and move)
https://jsfiddle.net/m5vxnpga/1/
Map in the correct position (original)
Map isn't always in the position that I choose
Hi @jtommy,
Thanks for opening this issue. I tried it 6 times and was not able to reproduce this issue.
Do you know how to reproduce it easily?
Do you have any error when this appends?
Micka
@KoRiGaN For example try to move the map on the right and zoom out, then click on "reset" button
Edit: I dont' have any errors in console
@KoRiGaN A workaround is for example:
this.zoom = 13
setTimeout(() => {
this.center = L.latLng(47.413220, -1.219482)
}, 1000)
but the effect is very ugly.
Hi @jtommy,
This issue seems to be that both center and zoom are changed in Leaflet using setView method, but this method takes time during animation.
The second call to setView (setting the center) seems to be ignored if the zoom change is still ongoing.
The best fix is to call the setView on the map directly:
this.$refs.map.setView(L.latLng(47.413220, -1.219482), 13);
@KoRiGaN Thanks!
It works but I have to access to internal mapObejct and I think it could be helpful have a same method in <l-map> component.
Hi @jtommy,
This issue seems to be that both center and zoom are changed in Leaflet using setView method, but this method takes time during animation.
The second call to setView (setting the center) seems to be ignored if the zoom change is still ongoing.The best fix is to call the setView on the map directly:
this.$refs.map.setView(L.latLng(47.413220, -1.219482), 13);
Well I don't have setView on may map object reference :(
But i realized that if i make a zoom and then a center, it works.
this.$refs.myMap.setZoom(coords.zoom)
this.$refs.myMap.setCenter([coords.lat, coords.long])
Most helpful comment
@KoRiGaN Thanks!
It works but I have to access to internal
mapObejctand I think it could be helpful have a same method in<l-map>component.