Skip to content
import MapViewConstraints from "@arcgis/core/views/2d/MapViewConstraints.js";
Inheritance:
MapViewConstraintsAccessor
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.

See also
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

Constructor
Parameters
ParameterTypeDescriptionRequired
properties
See the properties table for a list of all the properties that may be passed into the constructor.

Properties

Any properties can be set, retrieved or listened to. See the Watch for changes topic.

declaredClass

readonlyinherited Property
Type
string
Inherited from: Accessor
Since
ArcGIS Maps SDK for JavaScript 4.7

The name of the class. The declared class name is formatted as esri.folder.className.

effectiveLODs

readonly Property
Type
LOD[] | null

A read-only property that specifies the levels of detail (LODs) read from the Map.

effectiveMaxScale

readonly Property
Type
number

A read-only property that specifies the maximum scale the user is allowed to zoom to within the view.

effectiveMaxZoom

readonly Property
Type
number

A read-only property that specifies the maximum zoom level the user is allowed to zoom to within the view.

effectiveMinScale

readonly Property
Type
number

A read-only property that specifies the minimum scale the user is allowed to zoom to within the view.

effectiveMinZoom

readonly Property
Type
number

A read-only property that specifies the minimum zoom level the user is allowed to zoom to within the view.

geometry

autocast Property
Type
Extent | Polygon | null

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

autocast Property
Type
LOD[] | null

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.

maxScale

Property
Type
number

The maximum scale the user is allowed to zoom to within the view. Setting this value to 0 allows the user to overzoom layer tiles.

Default value
0

maxZoom

Property
Type
number

The maximum zoom level the user is allowed to zoom to within the view. Setting this value to 0 allows the user to over-zoom layer tiles.

Default value
-1

minScale

Property
Type
number

The minimum scale the user is allowed to zoom to within the view.

Default value
0

minZoom

Property
Type
number

The minimum zoom level the user is allowed to zoom to within the view.

Default value
-1

rotationEnabled

Property
Type
boolean

Indicates whether the user can rotate the map.

Default value
true

snapToZoom

Property
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