简体   繁体   English

如何关闭Google Maps V2上的可拖动行为(JavaScript)

[英]How to turn off dragable behaviour on Google Maps V2 (javascript)

I'm trying to set up a Google Maps on device and on top of it show some simple buttons. 我正在尝试在设备上设置Google地图,并在其顶部显示一些简单的按钮。 But events that I attach to those buttons seems to interferee somehow with map drag functionaliy. 但是我附加到这些按钮上的事件似乎在某种程度上干扰了地图拖动功能。 Basically drag completly doesnt work and also gives me this button not workin. 基本上完全拖动不起作用,也给我这个按钮不起作用。 I really dont care about this drag (I dont need it) - but i cant figure out how to disable it. 我真的不在乎这种拖动(我不需要它)-但我不知道如何禁用它。

Does any of you tried that? 你们中有人尝试过吗? (I dont want to use static google images only, I still want to have an option to move around, zoom in and out, but on my own buttons). (我不想只使用静态的Google图片,我仍然希望有一个选项可以四处移动,放大和缩小,但是要使用我自己的按钮)。 Biggest problem is markers - because I want to have them be clickable. 最大的问题是标记-因为我想让它们可点击。 So There might be 2 solutions: 因此,可能有两种解决方案:

  1. How to disable dragable behaviour? 如何禁用可拖动行为?

  2. How to make only markers clickable (outside of a Map layer somehow, but able to move together with map). 如何仅使标记可点击(以某种方式在地图图层之外,但能够与地图一起移动)。

I was thinking in hacky way to create an overlay that would pass only few events but this doesnt work... Anyone has any ideas? 我正在以一种怪异的方式考虑创建一个仅传递少量事件的叠加层,但这不起作用...任何人都有任何想法吗?

Thanks in advance, 提前致谢,

为了防止地图滚动,您必须在UiSettings上将ScrollGesturesEnabled设置为false:

googleMap.getUiSettings().setScrollGesturesEnabled(false);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM