Map.setGestureHandling
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ควบคุมวิธีจัดการท่าทางสัมผัสบนแผนที่
ดู https://developers.google.com/maps/documentation/javascript/reference/map#MapOptions.gestureHandling
การใช้งาน | การคืนสินค้า |
---|
Map.setGestureHandling(option) | |
อาร์กิวเมนต์ | ประเภท | รายละเอียด |
---|
option | สตริง | ตัวเลือกที่ควบคุมวิธีจัดการท่าทางสัมผัสบนแผนที่ ค่าที่อนุญาต
- "cooperative": เหตุการณ์การเลื่อนและท่าทางสัมผัสด้วยนิ้วเดียวจะเลื่อนหน้าเว็บ และจะไม่ซูมหรือเลื่อนแผนที่ ท่าทางสัมผัส 2 นิ้วจะเลื่อนและซูมแผนที่ การเลื่อนกิจกรรมโดยกดปุ่ม Ctrl หรือปุ่ม ⌘ จะซูมแผนที่ ในโหมดนี้ แผนที่จะทำงานร่วมกับหน้าเว็บ
- "greedy": ท่าทางสัมผัสทั้งหมดและเหตุการณ์การเลื่อนจะเลื่อนหรือซูมแผนที่
- "ไม่มี": ผู้ใช้จะเลื่อนหรือซูมแผนที่ไม่ได้
- "auto": (ค่าเริ่มต้น) การจัดการท่าทางสัมผัสจะเป็นแบบร่วมมือหรือแบบตะกละ ขึ้นอยู่กับว่าหน้าเว็บเลื่อนได้หรืออยู่ใน iframe
|
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\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. |"]]