公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
Map.setGestureHandling
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
控制地图上手势的处理方式。
请参阅 https://developers.google.com/maps/documentation/javascript/reference/map#MapOptions.gestureHandling。
用法 | 返回 |
---|
Map.setGestureHandling(option) | |
参数 | 类型 | 详细信息 |
---|
option | 字符串 | 用于控制如何在地图上处理手势的选项。允许的值:
- “cooperative”:滚动事件和单指触控手势会滚动网页,而不会缩放或平移地图。双指触摸手势可平移和缩放地图。按住 Ctrl 键或 ⌘ 键滚动鼠标滚轮可缩放地图。在此模式下,地图会与网页协同工作。
- “greedy”:所有触摸手势和滚动事件都会平移或缩放地图。
- “none”:用户无法通过手势平移或缩放地图。
- “auto”(默认):手势处理是协作式还是贪婪式,取决于网页是否可滚动或是否位于 iframe 中。
|
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003e\u003ccode\u003egestureHandling\u003c/code\u003e option controls how users interact with the map through gestures like scrolling and touch.\u003c/p\u003e\n"],["\u003cp\u003eOptions include "cooperative", "greedy", "none", and the default "auto", each affecting how the map responds to user input.\u003c/p\u003e\n"],["\u003cp\u003e"cooperative" allows page scrolling with one finger and map interaction with two fingers, while "greedy" makes all gestures control the map.\u003c/p\u003e\n"],["\u003cp\u003e"none" disables map panning and zooming via gestures, whereas "auto" intelligently switches between "cooperative" and "greedy" based on context.\u003c/p\u003e\n"],["\u003cp\u003eRefer to the Google Maps documentation for detailed information and implementation instructions.\u003c/p\u003e\n"]]],["The `Map.setGestureHandling(option)` method controls map gesture behavior. The `option` argument, a string, determines how the map interacts with user gestures. \"cooperative\" mode allows page scrolling with single-finger or scroll events while reserving two-finger gestures for map manipulation. \"greedy\" mode assigns all touch and scroll actions to the map. \"none\" disables map panning/zooming via gestures. \"auto\" (default) switches between cooperative and greedy modes.\n"],null,["# Map.setGestureHandling\n\n\u003cbr /\u003e\n\nControls how gestures are handled on the map.\n\n\u003cbr /\u003e\n\nSee https://developers.google.com/maps/documentation/javascript/reference/map#MapOptions.gestureHandling.\n\n| Usage | Returns |\n|----------------------------------|---------|\n| `Map.setGestureHandling(option)` | |\n\n| Argument | Type | Details |\n|----------|--------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `option` | String | The option that controls how gestures are handled on the map. Allowed values: - \"cooperative\": Scroll events and one-finger touch gestures scroll the page, and do not zoom or pan the map. Two-finger touch gestures pan and zoom the map. Scroll events with a ctrl key or ⌘ key pressed zoom the map. In this mode the map cooperates with the page. - \"greedy\": All touch gestures and scroll events pan or zoom the map. - \"none\": The map cannot be panned or zoomed by user gestures. - \"auto\": (default) Gesture handling is either cooperative or greedy, depending on whether the page is scrollable or in an iframe. |"]]