【发布时间】:2017-09-13 20:21:56
【问题描述】:
Leaflet 无法识别在我的应用程序中的触摸设备上双击(但双击缩放是可以的 - 只需打开开发工具并选择移动设备即可查看错误):https://express-tourism.herokuapp.com/
我认为这可能是因为我在另一个全局包装器 DIV 中有映射 DIV,但事实并非如此。即使我在控制台中输入“地图”,它也会显示 doubleClickZoom is enabled
我是否必须手动添加该双击功能或者我遗漏了什么?
更新:@Baptiste 是对的 - 我必须添加自定义双击功能:
var tapped=false
$("#map").on("touchstart",function(e){
if(!tapped){ //if tap is not set, set up single tap
tapped=setTimeout(function(){
tapped=null
//insert things you want to do when single tapped
},300); //wait 300ms then run single click code
} else { //tapped within 300ms of last tap. double tap
clearTimeout(tapped); //stop single tap callback
tapped=null
//insert things you want to do when double tapped
map.zoomIn(1)
}
});
【问题讨论】:
标签: javascript leaflet