问题描述
我使用谷歌地图的角度应用程序中的JavaScript API。当使用谷歌Chrome应用常规的台式机上使用鼠标,各种导航功能(旋转/缩放)申请就好了谷歌地图的一部分工作。然而,当我尝试在Windows 8.1的屏幕上使用触摸手势,地图不承认任何平底锅或缩放手势。如果我捏放大,没有任何反应。如果我加倍像鼠标在屏幕上点按,然后地图将放大。如果我用手指拖动时,浏览器窗口处理触摸事件,而不是地图格,所以左,右导航页历史,上下拖动滚动整个页面,而不是平移地图。
I am using Google Maps javascript API within an angular application. When using the app in Google Chrome on a regular desktop machine with a mouse, various navigation features (pan/zoom) work in the google maps part of the application just fine. However, when I try to use touch gestures on a windows 8.1 screen, the maps do not recognize any of the pan or zoom gestures. If I pinch to zoom, nothing happens. If I double tap on the screen like a mouse, then maps will zoom in. If I drag with a finger, the browser window handles the touch events instead of the maps div, so left and right navigates page history and up and down dragging scrolls the whole page instead of panning the maps.
作为另一项实验中,我尝试使用谷歌地图本身的Chrome里面,它工作得很好。因此,这意味着,它可以以某种方式进行....
As another experiment, I tried using google maps http://maps.google.com itself inside of Chrome, and it worked fine. So that means that it can be done somehow....
那么,是不是事情视区meta标签类型?或者它与大小的地图元素呢?或者是它的一个角的事情,我们需要做一些ngTouch莫名其妙地让应用程式响应触摸事件?
So, is it a viewport meta tag type of thing? Or does it have to do with sizing the map element? Or is it an angular thing and we need to do something with ngTouch somehow to allow the app to respond to touch events?
更新:触摸事件的做的在iPad上在同一页上的工作。我不知道那是什么说的,但它的令人鼓舞的是,至少它可以在移动Safari浏览器。看来我们需要沟通的东西角告诉它接受触摸事件。
Update: the touch events do work on the same page on an iPad. I'm not sure what that says, but it's encouraging that at least it works on mobile safari. It seems that we need to communicate something to Angular to tell it to accept the touch events.
推荐答案
这其实是一个谷歌地图错误的
This is in fact a Google Map bug #6425
乐趣的事实是,基于用户代理谷歌地图API不提供相同的内容。因此,对于一些使用情况下,解决办法是欺骗用户代理,乙醚是:
The fun fact is that Google Map API is not serving the same content based on the User Agent. So, for some use case, the workaround is to spoof the User Agent, ether by :
- Chrome浏览器开发工具>仿真>模型
- 一个用户代理欺骗扩展
- - 用户代理的镀铬标志
任何Android或iOS设备将工作,改变默认桌面谷歌地图应用程序一样移动。拖动和捏将在这个移动应用程序一样再次合作。
Any android or iOS device will work, changing the default desktop google map app to a mobile like app. Drag and pinch will work again on this mobile like app.
经过一番测试,即切换到喜欢的应用程序移动最小UA是铬或为AppleWebKit / 537,但它听起来危险使用它,因为它可能会在将来很好发生改变。
After some testing, the minimal UA that switches to the mobile like app is "Chrome" or "AppleWebKit/537", but it sounds hazardous to use it, as it may very well change in the future.
有关我的目的,基于Chrome kioks,这将这样的伎俩,直到错误是固定的。
For my purpose, chrome based kioks, this will do the trick until the bug is fixed.
这篇关于触摸事件不与谷歌地图合作的角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!