Javascript android webview中的鼠标按下事件
我有一段javascript代码,可以在传单地图中使用鼠标事件拖动一个圆圈,在网页中使用,而不是在android webview中使用,我的代码如下所示:Javascript android webview中的鼠标按下事件,javascript,android,webview,leaflet,Javascript,Android,Webview,Leaflet,我有一段javascript代码,可以在传单地图中使用鼠标事件拖动一个圆圈,在网页中使用,而不是在android webview中使用,我的代码如下所示: var isDragCircle = true; map.on('mouseup', function (){ isDragCircle = false; //showAndroidLog('mouse up event'); }); circle.on('mousedown', function (event) {
var isDragCircle = true;
map.on('mouseup', function (){
isDragCircle = false;
//showAndroidLog('mouse up event');
});
circle.on('mousedown', function (event) {
isDragCircle = true;
//showAndroidLog('mouse down event');
//L.DomEvent.stop(event);
map.dragging.disable();
let {lat: circleStartingLat, lng: circleStartingLng} = circle._latlng;
let {lat: mouseStartingLat, lng: mouseStartingLng} = event.latlng;
map.on('mousemove', event => {
if (isDragCircle) {
let {lat: mouseNewLat, lng: mouseNewLng} = event.latlng;
let latDifference = mouseStartingLat - mouseNewLat;
let lngDifference = mouseStartingLng - mouseNewLng;
let center = [circleStartingLat-latDifference, circleStartingLng-lngDifference];
circle.setLatLng(center);
};
});
});
map.on('click', function (e){
if (circleDrawn) {
circle.setLatLng(e.latlng);
};
});
在我的资产文件夹中的index.html中尝试此操作,但在webview中未触发mousedown事件,我的目标是从android webview中拖动传单圈
注意:还没有尝试使用usb otg的鼠标,但我想如何用触摸事件实现这一点
编辑:
仍在尝试但没有结果拖动圆,请临时使用“单击事件”更改圆坐标,如下所示:
var isDragCircle = true;
map.on('mouseup', function (){
isDragCircle = false;
//showAndroidLog('mouse up event');
});
circle.on('mousedown', function (event) {
isDragCircle = true;
//showAndroidLog('mouse down event');
//L.DomEvent.stop(event);
map.dragging.disable();
let {lat: circleStartingLat, lng: circleStartingLng} = circle._latlng;
let {lat: mouseStartingLat, lng: mouseStartingLng} = event.latlng;
map.on('mousemove', event => {
if (isDragCircle) {
let {lat: mouseNewLat, lng: mouseNewLng} = event.latlng;
let latDifference = mouseStartingLat - mouseNewLat;
let lngDifference = mouseStartingLng - mouseNewLng;
let center = [circleStartingLat-latDifference, circleStartingLng-lngDifference];
circle.setLatLng(center);
};
});
});
map.on('click', function (e){
if (circleDrawn) {
circle.setLatLng(e.latlng);
};
});
编辑:只需阅读传单文档(作为上下文菜单事件激发)