我需要能够注册事件回调来标记拖动事件,以便我可以运行反向查找并获取dragend
末尾的地址。另外,在拖动时,我需要在调试窗口中将“拖动”显示为文本。在 google map api 中这是可能的,但在 mapquest
icon api 中我无法找到文档。
我试过这个,
marker.on('dragend', function(e) {
popup.setLatLng(e.latlng).openOn(this);
reverseLookup(e.latlng, generatePopupContent);
});
e.latlng
返回未定义。
但是如果我对 map 对象使用相同的内容
map.on('click', function(f) {
popup.setLatLng(f.latlng).openOn(this);
reverseLookup(f.latlng, generatePopupContent);
});
f.latlng
返回格式正确的 latlng
我检查过 https://developer.mapquest.com/documentation/javascript-api/events/#poi_ ...
但是我如何为标记注册相同的事件。
最佳答案
以下是我在快速测试中的做法。
marker = L.marker([45, -120], {
draggable: true
})
.addTo(map)
.on('dragend', function(e){
console.log(e.target._latlng);
});
关于javascript - MapQuest 的标记事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50151688/