Map.setLocked
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
จำกัดการเลื่อนและซูมในแผนที่
- หากต้องการล็อกทั้งการเลื่อนและการซูม ให้ตั้งค่า "locked" เป็น "true" และไม่ต้องตั้งค่าอื่นๆ
- หากต้องการอนุญาตการเลื่อนและจำกัดการซูมต่ำสุดและสูงสุด ให้ตั้งค่า locked เป็น false และระบุพารามิเตอร์ minZoom และ maxZoom
- หากต้องการไม่อนุญาตการเลื่อนและจำกัดการซูมต่ำสุดและสูงสุด ให้ตั้งค่า locked เป็น true และระบุพารามิเตอร์ minZoom และ maxZoom
- หากต้องการรีเซ็ตแผนที่เป็นค่าเริ่มต้น ให้ตั้งค่า "locked" เป็น "false" และไม่ต้องตั้งค่าอื่น
การใช้งาน | การคืนสินค้า |
---|
Map.setLocked(locked, minZoom, maxZoom) | |
อาร์กิวเมนต์ | ประเภท | รายละเอียด |
---|
locked | บูลีน | ควรกำหนดให้ล็อกแผนที่หรือไม่ |
minZoom | หมายเลข (ไม่บังคับ) | (ไม่บังคับ) ระดับการซูมขั้นต่ำสำหรับแผนที่ ซึ่งอยู่ระหว่าง 0 ถึง 24 |
maxZoom | หมายเลข (ไม่บังคับ) | (ไม่บังคับ) การซูมสูงสุดสำหรับแผนที่ ซึ่งอยู่ระหว่าง 0 ถึง 24 รวม |
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003e\u003ccode\u003eMap.setLocked()\u003c/code\u003e enables control over map panning and zooming by setting the \u003ccode\u003elocked\u003c/code\u003e parameter.\u003c/p\u003e\n"],["\u003cp\u003eSetting \u003ccode\u003elocked\u003c/code\u003e to \u003ccode\u003etrue\u003c/code\u003e restricts map movement, while \u003ccode\u003efalse\u003c/code\u003e allows interaction.\u003c/p\u003e\n"],["\u003cp\u003eOptional \u003ccode\u003eminZoom\u003c/code\u003e and \u003ccode\u003emaxZoom\u003c/code\u003e parameters further refine zoom levels when \u003ccode\u003elocked\u003c/code\u003e is used.\u003c/p\u003e\n"],["\u003cp\u003eTo reset the map to default behavior, set \u003ccode\u003elocked\u003c/code\u003e to \u003ccode\u003efalse\u003c/code\u003e without specifying \u003ccode\u003eminZoom\u003c/code\u003e or \u003ccode\u003emaxZoom\u003c/code\u003e.\u003c/p\u003e\n"]]],["The `Map.setLocked()` function controls map panning and zooming. Setting `locked` to `true` disables panning. `minZoom` and `maxZoom` (0-24) define zoom limits, applicable whether panning is locked or not. Setting `locked` to `false` with no other parameters resets the map. To allow panning and limit zoom, set `locked` to false with `minZoom` and `maxZoom`. `True` `locked` with `minZoom` and `maxZoom` disallows panning but limits zooming.\n"],null,["# Map.setLocked\n\n\u003cbr /\u003e\n\nLimits panning and zooming on the map.\n\n\u003cbr /\u003e\n\n- To lock both panning and zooming, set locked to true and nothing else.\n\n- To allow panning and limit the min and max zoom, set locked to false and supply the minZoom and maxZoom parameters.\n\n- To disallow panning and limit min and max zoom, set locked to true and supply the minZoom and maxZoom parameters.\n\n- To reset the map to default, set locked to false and nothing else.\n\n| Usage | Returns |\n|----------------------------------------------------|---------|\n| `Map.setLocked(locked, `*minZoom* `, `*maxZoom*`)` | |\n\n| Argument | Type | Details |\n|-----------|------------------|-----------------------------------------------------------------------|\n| `locked` | Boolean | Whether the map should be locked or not. |\n| `minZoom` | Number, optional | (optional) The minimum zoom for the map, between 0 and 24, inclusive. |\n| `maxZoom` | Number, optional | (optional) The maximum zoom for the map, between 0 and 24, inclusive. |"]]