cod*_*iga 6 javascript leaflet mapbox
我目前正在使用leaflet.js并且我现在正在网上搜索相当多的内容,以找出:如果有事件,可以在异步函数setView()的动画结束后触发.
这是我试过的:
map.setView( [lat, lon ], 12 , {
pan: { animate: true , duration: 0.5 },
zoom: { animate: true },
animate: true
}.on('ready', function(e) {
console.log("animation finished!");
});
Run Code Online (Sandbox Code Playgroud)
setView-command工作正常,但是当map-animation准备就绪时应该触发的函数不起作用.
有没有人有办法解决吗?
您可以使用moveendsetView 完成后由 Leaflet 触发的事件:
http://leafletjs.com/reference.html#map-moveend
map.on('moveend', function(e){console.log("test")});
然而,每次移动地图时都会触发此操作,因此您需要在调用之前设置一些标志setView,并在处理程序中重置该平面moveend。
| 归档时间: |
|
| 查看次数: |
4105 次 |
| 最近记录: |