ui.Map.setGestureHandling
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Kiểm soát cách xử lý cử chỉ trên bản đồ.
Hãy xem https://developers.google.com/maps/documentation/javascript/reference/map#MapOptions.gestureHandling.
Cách sử dụng | Giá trị trả về |
---|
Map.setGestureHandling(option) | |
Đối số | Loại | Thông tin chi tiết |
---|
this: ui.map | ui.Map | Đối tượng ui.Map. |
option | Chuỗi | Lựa chọn kiểm soát cách xử lý cử chỉ trên bản đồ. Các giá trị được phép:
- "cooperative": Các sự kiện cuộn và cử chỉ chạm bằng một ngón tay sẽ cuộn trang chứ không thu phóng hoặc di chuyển bản đồ. Cử chỉ chạm bằng hai ngón tay sẽ di chuyển và thu phóng bản đồ. Sự kiện cuộn khi nhấn phím ctrl hoặc phím ⌘ sẽ thu phóng bản đồ. Ở chế độ này, bản đồ sẽ phối hợp với trang.
- "greedy": Tất cả cử chỉ chạm và sự kiện cuộn đều dịch chuyển hoặc thu phóng bản đồ.
- "none": Người dùng không thể dùng cử chỉ để di chuyển hoặc thu phóng bản đồ.
- "auto": (mặc định) Chế độ xử lý cử chỉ là phối hợp hoặc tham lam, tuỳ thuộc vào việc trang có thể cuộn hay nằm trong iframe.
|
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-26 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-26 UTC."],[[["\u003cp\u003eDefines how users interact with the map through gestures like scrolling, panning, and zooming.\u003c/p\u003e\n"],["\u003cp\u003eOffers four options: "cooperative", "greedy", "none", and the default "auto", to control gesture behavior.\u003c/p\u003e\n"],["\u003cp\u003e"Cooperative" mode prioritizes page scrolling over map interaction for single-finger gestures, while "greedy" mode prioritizes map interactions for all gestures.\u003c/p\u003e\n"],["\u003cp\u003eAllows developers to disable all gestures with the "none" option or let the map automatically determine the best gesture handling based on context with "auto".\u003c/p\u003e\n"],["\u003cp\u003eCan be set using the \u003ccode\u003eMap.setGestureHandling(option)\u003c/code\u003e method, where 'option' is one of the allowed string values.\u003c/p\u003e\n"]]],[],null,["# ui.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| this: `ui.map` | ui.Map | The ui.Map instance. |\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. |"]]