javascript - 如何禁用 Google map 移动布局上的滚动?

标签 javascript google-maps mobile

我正在开发通过 Google Maps API 嵌入 Google Maps 的移动网站。我已经能够阻止某些类型的行为,但无法找到阻止 map 滚动的好方法,因为我用手指向下滚动 iPhone 上的页面。这是我正在使用的代码:

<script>
function initialize() {
  var mapElem = document.getElementById("map"),
      myOptions = {
        zoom: 13,
        center: new google.maps.LatLng(41.8965,-84.063),
        navigationControl: true,
        navigationControlOptions: {
          style: google.maps.NavigationControlStyle.SMALL,
          position: google.maps.ControlPosition.TOP_RIGHT
        },
        streetViewControl: false,
        mapTypeControl: false,
        disableDoubleClickZoom: true,
        scrollwheel: false,
        backgroundColor: '#f2efe9',
        mapTypeId: google.maps.MapTypeId.ROADMAP
      },
      map = new google.maps.Map(mapElem, myOptions);
}
</script>
<script src='http://maps.google.com/maps/api/js?sensor=false&callback=initialize'></script>

提前致谢。

最佳答案

验证 ontouchend 是否在 document 中可用。

var myOptions = {
    // your other options...
    draggable: !("ontouchend" in document)
};
map = new google.maps.Map(mapElem, myOptions);

关于javascript - 如何禁用 Google map 移动布局上的滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4531052/

相关文章:

javascript - 当纬度和经度点数量很大时,谷歌地图无法正确绘制

javascript - 理解javascript借用方法

javascript - 空 mime 类型

javascript - 侧面导航栏下拉菜单

mobile - 从移动浏览器启动SMS

javascript - 为什么 (MouseUp mouseDown) 在移动浏览器上不起作用?

javascript - 如何使 FullCalendar 在触摸事件时适用于移动设备?

javascript - Parse Cloud Success 函数中的参数 :

javascript - 需要给谷歌地图地址来显示方向

google-maps - 带有 Storyboard的 Google ios sdk map View