Skip to content
import CoordinateConversionViewModel from "@arcgis/core/widgets/CoordinateConversion/CoordinateConversionViewModel.js";
Inheritance:
CoordinateConversionViewModelAccessor
Since
ArcGIS Maps SDK for JavaScript 4.7

Provides the logic for the CoordinateConversion widget and component.

See also

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.

conversions

autocast Property
Type
Collection<Conversion>

A Collection containing every Conversion that is currently displaying.

Example
// conversions can be set with an array of strings where each string is a format's name
coordinateConversion.conversions = ["mgrs"];

currentLocation

autocast Property
Type
Point | null | undefined

Describes the location of the coordinates currently displayed as a Point. Setting this property will update all conversions.

declaredClass

readonlyinherited Property
Type
string
Inherited from: Accessor

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

formats

autocast Property
Type
Collection<Format>

A Collection containing every Format that is capable of displaying.

The default formats are basemap, dd, ddm, dms, mgrs, usng, utm, and xy.

goToOverride

inherited Property
Type
GoToOverride | null | undefined
Inherited from: GoTo
Since
ArcGIS Maps SDK for JavaScript 4.8

This function provides the ability to override either the MapView goTo() or SceneView goTo() methods.

See also
Example
// The following snippet uses Search but can be applied to any
// widgets that support the goToOverride property.
search.goToOverride = function(view, goToParams) {
goToParams.options = {
duration: updatedDuration
};
return view.goTo(goToParams.target, goToParams.options);
};

locationSymbol

autocast Property
Type
SimpleMarkerSymbol | PictureMarkerSymbol | PointSymbol3D | CIMSymbol

This symbol is used to visualize the location currently, when capture mode is active.

mode

Property
Type
Mode

Describes the current mode.

  • While in live mode, updates occur as the cursor moves.
  • While in capture mode, updates occur on mouse click and then display a graphic marking the current location.
Default value
"live"

state

readonly Property
Type
CoordinateConversionViewModelState

The view model's state.

Default value
"disabled"

storageEnabled

Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 4.20

If this property is set to true, sessionStorage or localStorage (depending on storageType) will be used to hydrate and persist the CoordinateConversion's state.

Default value
true

storageType

Property
Type
"session" | "local"
Since
ArcGIS Maps SDK for JavaScript 4.23

This property determines whether sessionStorage or localStorage will be used to store state.

See also
Default value
"session"

view

Property
Type
MapViewOrSceneView | null | undefined

A reference to the MapView or SceneView. Set this to link to a specific view.

Methods

MethodSignatureClass
convert(format: Format, point: Point): Promise<Position>
emit
inherited
emit<Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean
goToLocation(point: Point): Promise<void>
hasEventListener
inherited
hasEventListener<Type extends EventNames<this>>(type: Type): boolean
on
inherited
on<Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle
pause(): void
previewConversion(conversion: Conversion, location?: Point): Promise<string | null | undefined>
resume(): void
reverseConvert(coordinate: string, format: Format): Promise<Point | null | undefined>
setLocation(point: Point | null | undefined): void
updateConversions(conversions: Conversion[], location: Point | null | undefined): Promise<Conversion[]>

convert

Method
Signature
convert (format: Format, point: Point): Promise<Position>

Attempt to convert a point into a Position.

Parameters
ParameterTypeDescriptionRequired
format

The format that describes how the point should be converted.

point

The point to convert.

Returns
Promise<Position>

When resolved, returns a Position.

emit

inherited Method
Signature
emit <Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean
Type parameters
<Type extends EventNames<this>>
Inherited from: EventedMixin

Emits an event on the instance. This method should only be used when creating subclasses of this class.

Parameters
ParameterTypeDescriptionRequired
type
Type

The name of the event.

event
this["@eventTypes"][Type]

The event payload.

Returns
boolean

true if a listener was notified

goToLocation

Method
Signature
goToLocation (point: Point): Promise<void>
Since
ArcGIS Maps SDK for JavaScript 4.34

Goes to a location in the view associated with the view model

See also
Parameters
ParameterTypeDescriptionRequired
point

The location to go to

Returns
Promise<void>

hasEventListener

inherited Method
Signature
hasEventListener <Type extends EventNames<this>>(type: Type): boolean
Type parameters
<Type extends EventNames<this>>
Inherited from: EventedMixin

Indicates whether there is an event listener on the instance that matches the provided event name.

Parameters
ParameterTypeDescriptionRequired
type
Type

The name of the event.

Returns
boolean

Returns true if the class supports the input event.

on

inherited Method
Signature
on <Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle
Type parameters
<Type extends EventNames<this>>
Inherited from: EventedMixin

Registers an event handler on the instance. Call this method to hook an event with a listener.

Parameters
ParameterTypeDescriptionRequired
type
Type

An event or an array of events to listen for.

listener
EventedCallback<this["@eventTypes"][Type]>

The function to call when the event fires.

Returns
ResourceHandle

Returns an event handler with a remove() method that should be called to stop listening for the event(s).

PropertyTypeDescription
removeFunctionWhen called, removes the listener from the event.
Example
view.on("click", function(event){
// event is the event handle returned after the event fires.
console.log(event.mapPoint);
});

pause

Method
Signature
pause (): void
Since
ArcGIS Maps SDK for JavaScript 4.34

Pauses the view model's operation. See the resume() method

Returns
void

previewConversion

Method
Signature
previewConversion (conversion: Conversion, location?: Point): Promise<string | null | undefined>

Generates a localized coordinate string suitable for display given a Conversion and a Point

Parameters
ParameterTypeDescriptionRequired
conversion

Specifies the format to use to preview

location

The position to preview

Returns
Promise<string | null | undefined>

resume

Method
Signature
resume (): void
Since
ArcGIS Maps SDK for JavaScript 4.34

Resumes the view model's operation. See the pause() method

Returns
void

reverseConvert

Method
Signature
reverseConvert (coordinate: string, format: Format): Promise<Point | null | undefined>

Attempt to convert a string into a Point. The format of the string must be specified. A Collection of available formats can be obtained from the formats property.

Parameters
ParameterTypeDescriptionRequired
coordinate

The coordinate string.

format

Specifies the format of the input coordinate.

Returns
Promise<Point | null | undefined>

When resolved, returns a Point.

setLocation

Method
Signature
setLocation (point: Point | null | undefined): void
Since
ArcGIS Maps SDK for JavaScript 4.34

Set the view model's new location to the input Point

Parameters
ParameterTypeDescriptionRequired
point

The point to be set as the new location.

Returns
void

updateConversions

Method
Signature
updateConversions (conversions: Conversion[], location: Point | null | undefined): Promise<Conversion[]>

Update the input conversions based on the input point.

Parameters
ParameterTypeDescriptionRequired
conversions

An array of Conversions to be updated.

location

A point that will be used to update each input conversion.

Returns
Promise<Conversion[]>

When resolved, returns an array of Conversions with updated Positions.

Type definitions

CoordinateConversionViewModelState

Type definition
Type
"ready" | "loading" | "disabled"