Pointers 传单:如何处理触摸事件(例如在移动设备上)

Pointers 传单:如何处理触摸事件(例如在移动设备上),pointers,events,leaflet,touch,mouse,Pointers,Events,Leaflet,Touch,Mouse,请看下面的代码。它正在地图上画一个圆圈。如果用户用鼠标单击,或用手指(在移动设备上)点击并拖动圆圈,则应在地图上移动圆圈 这适用于桌面Firefox、桌面Chrome和移动Firefox。但是没有使用移动Chrome。我认为移动Firefox中的代码可能只是起作用,因为浏览器模拟了触摸输入到鼠标输入,这当然在传单中工作得很好 所以我需要帮助如何在传单中最好地实现触摸事件(与鼠标事件平行)。传单文档中未提及触摸事件。但我认为通常的Javascript DOM事件也应该起作用?(touchstart

请看下面的代码。它正在地图上画一个圆圈。如果用户用鼠标单击,或用手指(在移动设备上)点击并拖动圆圈,则应在地图上移动圆圈

这适用于桌面Firefox、桌面Chrome和移动Firefox。但是没有使用移动Chrome。我认为移动Firefox中的代码可能只是起作用,因为浏览器模拟了触摸输入到鼠标输入,这当然在传单中工作得很好

所以我需要帮助如何在传单中最好地实现触摸事件(与鼠标事件平行)。传单文档中未提及触摸事件。但我认为通常的Javascript DOM事件也应该起作用?(touchstart、touchmove、touchend)。但在Chrome mobile中,我的代码编写方式是不一样的


事件测试
var mymap=L.map('mapid').setView([51.505,-0.09],13);
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyj1ijoibwwwwym94iiwiysi6imnpejy4nxvycta2emycxbdhrqcmz3n3gifq.rjfig214ariislb6b5aw'{
maxZoom:18,
属性:“映射数据©;贡献者”+
', ' +
“图像”,
id:“地图盒。街道”
}).addTo(mymap);
圆=L.圆([51.508,-0.11],500{
颜色:“红色”,
填充颜色:“#f03”,
填充不透明度:0.5
}).addTo(mymap);
圆圈.on('mousedown touchstart',onCircleDown);
函数onCircleDown(e1){
mymap.dragging.disable();
var mouseStartingLat=e1.latlng.lat;
var mouseStartingLng=e1.latlng.lng;
var circleStartingLat=e1.目标_latlng.lat;
var circleStartingLng=e1.目标值_latlng.lng;
圆圈.on('mousemove',函数(e2){
var mouseNewLat=e2.latlng.lat;
var mouseNewLng=e2.latlng.lng;
var latDifference=mouseNewLat-mouseStartingLat;
var lngDifference=mouseNewLng-mouseStartingLng;
var currentCircleCoords=L.latLng(circleStartingLat+latDifference,circleStartingLng+lngDifference);
e1.target.setLatLng(currentCircleCoords);
});
circle.on('mouseup',函数(){
圈.off('mousemove');
mymap.draging.enable();
});
}