本文介绍了如何禁用Google地图移动版面上的滚动功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发通过Google地图API嵌入Google地图的移动网站。我已经能够阻止某些类型的行为,但一直无法找到一种好方法,当我在iPhone上向下滚动页面时,停止滚动地图。这里是我使用的代码:

 < script> 
函数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 文档中是否可用。

  var myOptions = {
//您的其他选项...
可拖动:!(ontouchend in document)
};
map = new google.maps.Map(mapElem,myOptions);


I am developing mobile sites with Google Maps embedded via the Google Maps API. I have been able to stop certain types of behavior but have been unable to find a good way to stop the map from scrolling as I finger scroll down the page on the iPhone. Here is the code I am using:

<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>

Thanks in advance.

解决方案

Validate whether ontouchend is available in document.

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

这篇关于如何禁用Google地图移动版面上的滚动功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 05:56