import CoordinateConversionViewModel from "@arcgis/core/widgets/CoordinateConversion/CoordinateConversionViewModel.js";const CoordinateConversionViewModel = await $arcgis.import("@arcgis/core/widgets/CoordinateConversion/CoordinateConversionViewModel.js");- Inheritance:
- CoordinateConversionViewModel→
Accessor
- Since
- ArcGIS Maps SDK for JavaScript 4.7
Provides the logic for the CoordinateConversion widget and component.
- See also
CoordinateConversion widget - Deprecated since 4.34. Use the Coordinate Conversion component instead.
Constructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Properties
| Property | Type | Class |
|---|---|---|
| | ||
| | ||
declaredClass readonly inherited | ||
| | ||
goToOverride inherited | ||
| | ||
| | ||
state readonly | | |
| | ||
"session" | "local" | | |
| |
conversions
- 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 namecoordinateConversion.conversions = ["mgrs"]; formats
- 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
- Type
- GoToOverride | null | undefined
- 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
This symbol is used to visualize the location currently, when capture mode
is active.
mode
- Type
- Mode
Describes the current mode.
- While in
livemode, updates occur as the cursor moves. - While in
capturemode, updates occur on mouse click and then display a graphic marking the current location.
- Default value
- "live"
storageEnabled
- 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
view
- Type
- MapViewOrSceneView | null | undefined
Methods
| Method | Signature | Class |
|---|---|---|
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
- Signature
-
convert (format: Format, point: Point): Promise<Position>
Attempt to convert a point into a Position.
emit
- Signature
-
emit <Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean
- Type parameters
- <Type extends EventNames<this>>
Emits an event on the instance. This method should only be used when creating subclasses of this class.
hasEventListener
- Signature
-
hasEventListener <Type extends EventNames<this>>(type: Type): boolean
- Type parameters
- <Type extends EventNames<this>>
Indicates whether there is an event listener on the instance that matches the provided event name.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| type | Type | The name of the event. | |
- Returns
- boolean
Returns true if the class supports the input event.
on
- Signature
-
on <Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle
- Type parameters
- <Type extends EventNames<this>>
Registers an event handler on the instance. Call this method to hook an event with a listener.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| 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).Property Type Description remove Function When 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);}); previewConversion
- Signature
-
previewConversion (conversion: Conversion, location?: Point): Promise<string | null | undefined>
Generates a localized coordinate string suitable for display given a Conversion and a Point
reverseConvert
- 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.
setLocation
- 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
updateConversions
- Signature
-
updateConversions (conversions: Conversion[], location: Point | null | undefined): Promise<Conversion[]>
Update the input conversions based on the input point.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| 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.