Map.setLocked
Limits panning and zooming on the map.
- To lock both panning and zooming, set locked to true and nothing else.
- To allow panning and limit the min and max zoom, set locked to false and supply the minZoom and maxZoom parameters.
- To disallow panning and limit min and max zoom, set locked to true and supply the minZoom and maxZoom parameters.
- To reset the map to default, set locked to false and nothing else.
Usage | Returns |
---|
Map.setLocked(locked, minZoom, maxZoom) | |
Argument | Type | Details |
---|
locked | Boolean | Whether the map should be locked or not. |
minZoom | Number, optional | (optional) The minimum zoom for the map, between 0 and 24, inclusive. |
maxZoom | Number, optional | (optional) The maximum zoom for the map, between 0 and 24, inclusive. |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-10-06 UTC.
[null,null,["Last updated 2023-10-06 UTC."],[[["`Map.setLocked()` enables control over map panning and zooming by setting the `locked` parameter."],["Setting `locked` to `true` restricts map movement, while `false` allows interaction."],["Optional `minZoom` and `maxZoom` parameters further refine zoom levels when `locked` is used."],["To reset the map to default behavior, set `locked` to `false` without specifying `minZoom` or `maxZoom`."]]],["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"]]