Skip to content
import ViewState from "@arcgis/core/views/2d/ViewState.js";
Inheritance:
ViewStateAccessor
Since
ArcGIS Maps SDK for JavaScript 4.8

Object that holds information about the MapView state.

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.
PropertyTypeClass
center
readonly
[ number, number ]
declaredClass
readonly inherited
extent
readonly
resolution
readonly
rotation
readonly
scale
readonly
size
readonly
[ number, number ]

center

readonly Property
Type
[ number, number ]

Represents the view's center point as an array of two numbers [x, y].

See also

declaredClass

readonlyinherited Property
Type
string
Inherited from: Accessor

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

extent

readonly Property
Type
Extent

The extent represents the visible portion of a map within the view as an instance of Extent.

See also

resolution

readonly Property
Type
number
Since
ArcGIS Maps SDK for JavaScript 4.9

Represents the size of one pixel in map units. The value of resolution is the result of the division of the extent width by the size.

Default value
0

rotation

readonly Property
Type
number

The clockwise rotation of due north in relation to the top of the view in degrees.

See also
Default value
0

scale

readonly Property
Type
number

Represents the map scale at the center of the view.

See also
Default value
0

size

readonly Property
Type
[ number, number ]

Represents the width and height of the view in pixels, e.g. [width, height].

See also

Methods

MethodSignatureClass
fromJSON
inherited static
fromJSON(json: any): any
clone(): ViewState
copy(state: ViewState): this
toJSON
inherited
toJSON(): any
toMap(out: [ number, number ], x: number, y: number): [ number, number ]
toScreen(out: [ number, number ], x: number, y: number): [ number, number ]
toScreenNoRotation(out: [ number, number ], x: number, y: number): [ number, number ]

fromJSON

inheritedstatic Method
Signature
fromJSON (json: any): any
Inherited from: JSONSupportMixin

Creates a new instance of this class and initializes it with values from a JSON object generated from an ArcGIS product. The object passed into the input json parameter often comes from a response to a query operation in the REST API or a toJSON() method from another ArcGIS product. See the Using fromJSON() topic in the Guide for details and examples of when and how to use this function.

Parameters
ParameterTypeDescriptionRequired
json
any

A JSON representation of the instance in the ArcGIS format. See the ArcGIS REST API documentation for examples of the structure of various input JSON objects.

Returns
any

Returns a new instance of this class.

clone

Method
Signature
clone (): ViewState

Creates a deep clone of ViewState object.

Returns
ViewState

A new instance of a ViewState object equal to the object used to call .clone().

copy

Method
Signature
copy (state: ViewState): this

Copies the properties from a given view state.

Parameters
ParameterTypeDescriptionRequired
state

The view state to copy the properties from.

Returns
this

This ViewState instance.

toJSON

inherited Method
Signature
toJSON (): any
Inherited from: JSONSupportMixin

Converts an instance of this class to its ArcGIS portal JSON representation. See the Using fromJSON() guide topic for more information.

Returns
any

The ArcGIS portal JSON representation of an instance of this class.

toMap

Method
Signature
toMap (out: [ number, number ], x: number, y: number): [ number, number ]

Converts the x and y screen coordinates to map coordinates.

Parameters
ParameterTypeDescriptionRequired
out
[ number, number ]

The receiving array of the conversion.

x

The horizontal screen coordinate to convert.

y

The vertical screen coordinate to convert.

Returns
[ number, number ]

The receiving array of the conversion.

toScreen

Method
Signature
toScreen (out: [ number, number ], x: number, y: number): [ number, number ]

Converts the x and y map coordinates to screen coordinates.

Parameters
ParameterTypeDescriptionRequired
out
[ number, number ]

The receiving array of the conversion.

x

The horizontal screen coordinate to convert.

y

The vertical screen coordinate to convert.

Returns
[ number, number ]

The receiving array of the conversion.

toScreenNoRotation

Method
Signature
toScreenNoRotation (out: [ number, number ], x: number, y: number): [ number, number ]

Converts the x and y map coordinates to screen coordinates. This method is similar to toScreen(), without applying the view state rotation.

Parameters
ParameterTypeDescriptionRequired
out
[ number, number ]

The receiving array of the conversion.

x

The horizontal screen coordinate to convert.

y

The vertical screen coordinate to convert.

Returns
[ number, number ]

The receiving array of the conversion.