1
我想在touchmove事件(傳單地圖)中獲取觸點的LatLng。我沒有找到解決這個問題的方法。有什麼方法可以獲得座標嗎?如何在傳單上獲取LatLng的觸摸
$(document).on('touchmove', '#mapid', function(e) {
//here i want to get the LatLng coordinates
)};
我想在touchmove事件(傳單地圖)中獲取觸點的LatLng。我沒有找到解決這個問題的方法。有什麼方法可以獲得座標嗎?如何在傳單上獲取LatLng的觸摸
$(document).on('touchmove', '#mapid', function(e) {
//here i want to get the LatLng coordinates
)};
我看到兩種方法。
一個是使用Leaflet的事件處理,y做類似map.on('mousemove', function(ev){ ... });
。
該事件處理程序將收到一個Leaflet'MouseEvent',其中包含發生事件的地圖點的LngLat
。請參閱http://leafletjs.com/reference-1.1.0.html#map-event和http://leafletjs.com/reference-1.1.0.html#mouseevent。是的,傳單會在聽到MouseEvent
s的時候收聽TouchEvent
s和PointerEvent
s。
另一種方法是使用map's containerPointToLatLng()
conversion method或mouseEventToLatLng()
method將像素座標或鼠標事件轉換爲LatLng
。
傳單LatLng鼠標事件的方法不適用於觸摸真實移動設備 – padeg