Javascript 地图平移时的传单.js火灾事件
当输入新的GPS坐标时,我在主干视图上使用此功能:Javascript 地图平移时的传单.js火灾事件,javascript,leaflet,dom-events,Javascript,Leaflet,Dom Events,当输入新的GPS坐标时,我在主干视图上使用此功能: onLocationFound: function(position){ // this function runs every time we get a valid GPS fix // here I have some preparation code, like getting "position" if(myApp.mapView.hasCenter){ this.m
onLocationFound: function(position){
// this function runs every time we get a valid GPS fix
// here I have some preparation code, like getting "position"
if(myApp.mapView.hasCenter){
this.map.panTo(position.coords.latlng);
}
},
然后,在另一段代码中运行此函数:
this.map.on("moveend", function(s){
that.doDrawReports();
});
我的问题是
moveend
事件没有捕获我的panTo
操作。我怎样才能抓住它?无法复制您的问题抱歉:
- 附传单0.7.7:
- 附传单1.0.0-beta.2:
var-map=L.map(“map”).setView([48.86,2.35],12);
setInterval(函数(){
var currentPos=map.getCenter();
潘托地图([
当前位置lat,
当前位置液化天然气+0.1
])
}, 2000);
map.on(“moveend”,函数(){
log(map.getCenter().toString());
});
即使将间隔减小到50ms,仍然会调用
moveend
侦听器。您确定“在您的另一段代码中”this.map
实际包含L.map
实例吗?听起来像是范围界定问题。这个.map是L.map
。我敢肯定。我想是别的地方出了错。我的代码有点难测试,但这有助于隔离问题,并证明panTo
触发事件move*
。