我正在开发通过 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/