【问题标题】:Leaflet double tap does not zoom in传单双击不放大
【发布时间】: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


    【解决方案1】:

    Leaflet 不能在移动设备上双击进行缩放,您需要两根手指。您可以查看此设置http://leafletjs.com/reference-1.2.0.html#map-tap 并将其添加到您的地图中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-11
      • 2017-10-27
      • 1970-01-01
      • 1970-01-01
      • 2011-03-07
      • 1970-01-01
      • 1970-01-01
      • 2011-03-12
      相关资源
      最近更新 更多