禁用谷歌地图上的捏缩放[桌面] [英] Disabling pinch-zoom on google maps [Desktop]

查看:101
本文介绍了禁用谷歌地图上的捏缩放[桌面]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Google Maps API v3的网站,我无法让pinch-zoom属性正常工作。

这是一款具有触摸功能的PC显示器,它不是捏放缩放的手势。所以,因为我无法正常工作,我决定禁用该功能。



我使用下面的

  document.documentElement取消了触摸事件。 ontouchstart = function(){return false} 

这有一个不需要的副作用。此代码会取消整个触摸事件,因此用户无法使用Google Maps默认缩放控件。我尝试将'ontouchstart'更改为'ontouchmove'事件,但这并不妨碍地图缩小。



有关如何禁用该功能的任何建议或可能如何解决捏到缩放功能?
我可以发布网站的网址,但它只是一个简单的谷歌地图,你不会注意到这个问题,除非你有一个触摸启用监视器。

解决方案

这里有一个类似问题的人用这种方式解决了问题,也许它适用于你

  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



这里

>

如何禁用Android中的pinch MapView


I have a website which uses Google Maps API v3 and i couldn't get the pinch-zoom property to work properly. Instead of a Pinch-to-Zoom-In, the gesture always performs a Zoom-Out.

This is a PC monitor with Touch capability. So, as i was unable to get it work properly, i decided to disable the feature.

I cancelled the touch event using below

document.documentElement.ontouchstart = function() {return false}

This has an unwanted side-effect. This code cancels the entire touch events and hence user cannot use the Google Maps default Zoom control. I tried changing the 'ontouchstart' to a 'ontouchmove' event but this is not preventing the map from zooming out.

Any ideas on how to disable the feature or may be how to fix the pinch-to-zoomIn feature? I can post the website url but its just a plain google map and you will not notice the issue unless if you a have touch enabled monitor.

解决方案

Here someone with a similar problem solved it this way, maybe it will work for you

var tblock = function (e) {
if (e.touches.length > 1) {
    e.preventDefault()
}

return false;
}

document.body.addEventListener("touchmove", tblock, true);

Google Maps API v3 Disable Pinch to Zoom on iPad Safari

And here

How to disable pinch in Android MapView

这篇关于禁用谷歌地图上的捏缩放[桌面]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆