Google Maps API v3在iPad Safari上禁用缩放 [英] Google Maps API v3 Disable Pinch to Zoom on iPad Safari
问题描述
我正在尝试弄清楚如何在Javascript上禁用Google Maps API V3中的默认缩放功能。我试着检测文档和嵌套div上的touchstart事件,但无济于事。任何人有任何想法如何我可以禁用此功能?
笔记
我尝试遍历所有的DOM元素寻找 ontouchstart
事件在寻找一种可能构建黑客的方式的时间间隔,但我似乎无法找到任何(使用我的iPad),所以我不确定他们是如何即使是这样。
我想出了一个解决方案,因为我的项目是全屏幕, (e.touches.length> 1){
>
var tblock = function(e){
if e.preventDefault()
}
return false;
}
document.body.addEventListener(touchmove,tblock,true);
I am trying to figure out how to disable the default pinch to zoom functionality on the Google Maps API V3 with Javascript. I tried detecting the touchstart events on the document and nested divs but to no avail. Anyone have any ideas how I can disable this functionality?
Notes
I have tried iterating through all the DOM elements looking for the ontouchstart
events on an interval looking for a way to potentially build a hack but I can't seem to locate any at (using my iPad), so I am unsure how they are even doing it.
I figured out a solution, since my project is full screen the following code did the trick.
var tblock = function (e) {
if (e.touches.length > 1) {
e.preventDefault()
}
return false;
}
document.body.addEventListener("touchmove", tblock, true);
这篇关于Google Maps API v3在iPad Safari上禁用缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!