import MapViewConstraints from "@arcgis/core/views/2d/MapViewConstraints.js";const MapViewConstraints = await $arcgis.import("@arcgis/core/views/2d/MapViewConstraints.js");- Inheritance:
- MapViewConstraints→
Accessor
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Specifies constraints to scale, zoom, and rotation that may be applied to the MapView.
The constraints.lods should be set in the MapView constructor, if the map does not have a basemap or when the basemap does not have TileInfo.
Examples
view.constraints = { geometry: { // Constrain lateral movement to Lower Manhattan type: "extent", xmin: -74.020, ymin: 40.700, xmax: -73.971, ymax: 40.73 }, minScale: 500000, // User cannot zoom out beyond a scale of 1:500,000 maxScale: 0, // User can overzoom tiles rotationEnabled: false // Disables map rotation// This snippet shows how to set the MapView scale 1:1 while generating additional LODs for the MapView.constraints. const spatialReference = new SpatialReference({ wkid: 2154 }); const center = new Point({ x: 0, y: 0, spatialReference });
// Create LODs from level 0 to 31 const tileInfo = TileInfo.create({ spatialReference, numLODs: 32 }); const lods = tileInfo.lods;
let view = new MapView({ container: "viewDiv", map, scale: 1, center, spatialReference, constraints: { lods: lods, snapToZoom: false } });Constructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Properties
| Property | Type | Class |
|---|---|---|
declaredClass readonly inherited | ||
effectiveLODs readonly | | |
effectiveMaxScale readonly | | |
effectiveMaxZoom readonly | | |
effectiveMinScale readonly | | |
effectiveMinZoom readonly | | |
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| |
geometry
The area in which the user is allowed to navigate laterally. Only Extent and Polygon geometry types are supported. Z-values are ignored. This property is honored by interactive MapView navigation and MapView.goTo(). This property may be autocast.
lods
An array of LODs. If not specified, this value is read from the Map. It is possible to generate additional LODs via the TileInfo.create() method. This is useful in cases where the default amount of LODs provided are not sufficient. One example of when this is needed is when setting the view scale 1
. Additionally, this property may be autocast. rotationEnabled
- Type
- boolean
Indicates whether the user can rotate the map.
- Default value
- true
snapToZoom
- Type
- boolean
When true, the view snaps to the next LOD when zooming in or out. When false, the zoom is continuous. This does not apply when zooming in/out using two finger pinch in/out.
- Default value
- true