UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

199 lines (196 loc) • 11.8 kB
import type Collection from "../../core/Collection.js"; import type Point from "../../geometry/Point.js"; import type CIMSymbol from "../../symbols/CIMSymbol.js"; import type PictureMarkerSymbol from "../../symbols/PictureMarkerSymbol.js"; import type PointSymbol3D from "../../symbols/PointSymbol3D.js"; import type SimpleMarkerSymbol from "../../symbols/SimpleMarkerSymbol.js"; import type Conversion from "./support/Conversion.js"; import type Format from "./support/Format.js"; import type { ReadonlyArrayOrCollection } from "../../core/Collection.js"; import type { EventedAccessor } from "../../core/Evented.js"; import type { MapViewOrSceneView } from "../../views/MapViewOrSceneView.js"; import type { Mode, Position } from "../types.js"; import type { ConversionProperties } from "./support/Conversion.js"; import type { GoTo, GoToProperties } from "../support/GoTo.js"; import type { PointProperties } from "../../geometry/Point.js"; import type { FormatProperties } from "./support/Format.js"; import type { CIMSymbolProperties } from "../../symbols/CIMSymbol.js"; import type { PointSymbol3DProperties } from "../../symbols/PointSymbol3D.js"; import type { PictureMarkerSymbolProperties } from "../../symbols/PictureMarkerSymbol.js"; import type { SimpleMarkerSymbolProperties } from "../../symbols/SimpleMarkerSymbol.js"; export interface CoordinateConversionViewModelProperties extends GoToProperties, Partial<Pick<CoordinateConversionViewModel, "mode" | "storageEnabled" | "storageType" | "view">> { /** * A [Collection](https://developers.arcgis.com/javascript/latest/references/core/core/Collection/) containing every [Conversion](https://developers.arcgis.com/javascript/latest/references/core/widgets/CoordinateConversion/support/Conversion/) * that is currently displaying. * * @since 4.7 * @example * // conversions can be set with an array of strings where each string is a format's name * coordinateConversion.conversions = ["mgrs"]; */ conversions?: ReadonlyArrayOrCollection<ConversionProperties>; /** * Describes the location of the coordinates currently displayed as a [Point](https://developers.arcgis.com/javascript/latest/references/core/geometry/Point/). * Setting this property will update all [conversions](https://developers.arcgis.com/javascript/latest/references/core/widgets/CoordinateConversion/CoordinateConversionViewModel/#conversions). * * @since 4.7 */ currentLocation?: PointProperties | null; /** * A [Collection](https://developers.arcgis.com/javascript/latest/references/core/core/Collection/) containing every [Format](https://developers.arcgis.com/javascript/latest/references/core/widgets/CoordinateConversion/support/Format/) * that is capable of displaying. * * The default formats are `basemap`, `dd`, `ddm`, `dms`, `mgrs`, `usng`, `utm`, and `xy`. */ formats?: ReadonlyArrayOrCollection<FormatProperties>; /** * This symbol is used to visualize the location currently, when `capture` mode * is active. */ locationSymbol?: (SimpleMarkerSymbolProperties & { type: "simple-marker" }) | (PictureMarkerSymbolProperties & { type: "picture-marker" }) | (PointSymbol3DProperties & { type: "point-3d" }) | (CIMSymbolProperties & { type: "cim" }); } export type CoordinateConversionViewModelState = "ready" | "loading" | "disabled"; /** * Provides the logic for the [CoordinateConversion](https://developers.arcgis.com/javascript/latest/references/core/widgets/CoordinateConversion/) widget and [component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-coordinate-conversion/). * * @since 4.7 * @see [CoordinateConversion widget](https://developers.arcgis.com/javascript/latest/references/core/widgets/CoordinateConversion/) - _Deprecated since 4.34. Use the [Coordinate Conversion component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-coordinate-conversion/) instead._ * @see [Coordinate Conversion component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-coordinate-conversion/) * @see [Sample - CoordinateConversion component](https://developers.arcgis.com/javascript/latest/sample-code/coordinate-conversion/) */ export default class CoordinateConversionViewModel extends CoordinateConversionViewModelSuperclass { constructor(properties?: CoordinateConversionViewModelProperties); /** * A [Collection](https://developers.arcgis.com/javascript/latest/references/core/core/Collection/) containing every [Conversion](https://developers.arcgis.com/javascript/latest/references/core/widgets/CoordinateConversion/support/Conversion/) * that is currently displaying. * * @since 4.7 * @example * // conversions can be set with an array of strings where each string is a format's name * coordinateConversion.conversions = ["mgrs"]; */ get conversions(): Collection<Conversion>; set conversions(value: ReadonlyArrayOrCollection<ConversionProperties>); /** * Describes the location of the coordinates currently displayed as a [Point](https://developers.arcgis.com/javascript/latest/references/core/geometry/Point/). * Setting this property will update all [conversions](https://developers.arcgis.com/javascript/latest/references/core/widgets/CoordinateConversion/CoordinateConversionViewModel/#conversions). * * @since 4.7 */ get currentLocation(): Point | null | undefined; set currentLocation(value: PointProperties | null | undefined); /** * A [Collection](https://developers.arcgis.com/javascript/latest/references/core/core/Collection/) containing every [Format](https://developers.arcgis.com/javascript/latest/references/core/widgets/CoordinateConversion/support/Format/) * that is capable of displaying. * * The default formats are `basemap`, `dd`, `ddm`, `dms`, `mgrs`, `usng`, `utm`, and `xy`. */ get formats(): Collection<Format>; set formats(value: ReadonlyArrayOrCollection<FormatProperties>); /** * This symbol is used to visualize the location currently, when `capture` mode * is active. */ get locationSymbol(): SimpleMarkerSymbol | PictureMarkerSymbol | PointSymbol3D | CIMSymbol; set locationSymbol(value: (SimpleMarkerSymbolProperties & { type: "simple-marker" }) | (PictureMarkerSymbolProperties & { type: "picture-marker" }) | (PointSymbol3DProperties & { type: "point-3d" }) | (CIMSymbolProperties & { type: "cim" })); /** * 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 "live" * @since 4.7 */ accessor mode: Mode; /** * The view model's state. * * @default "disabled" */ get state(): CoordinateConversionViewModelState; /** * If this property is set to `true`, sessionStorage or localStorage (depending on [storageType](https://developers.arcgis.com/javascript/latest/references/core/widgets/CoordinateConversion/CoordinateConversionViewModel/#storageType)) * will be used to hydrate and persist the CoordinateConversion's state. * * @default true * @since 4.20 */ accessor storageEnabled: boolean; /** * This property determines whether sessionStorage or localStorage will be used to store state. * * @default "session" * @since 4.23 * @see [Window.sessionStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage) * @see [Window.localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) */ accessor storageType: "session" | "local"; /** A reference to the [MapView](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/) or [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/). Set this to link to a specific view. */ accessor view: MapViewOrSceneView | null | undefined; /** * Attempt to convert a point into a [Position](https://developers.arcgis.com/javascript/latest/references/core/widgets/types/#Position). * * @param format - The format that describes how the point should be converted. * @param point - The point to convert. * @returns When resolved, returns a [Position](https://developers.arcgis.com/javascript/latest/references/core/widgets/types/#Position). */ convert(format: Format, point: Point): Promise<Position>; /** * Goes to a location in the view associated with the view model * * @param point - The location to go to * @since 4.34 * @see [MapView.goTo()](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/#goTo) */ goToLocation(point: Point): Promise<void>; /** * Pauses the view model's operation. See the [resume()](https://developers.arcgis.com/javascript/latest/references/core/widgets/CoordinateConversion/CoordinateConversionViewModel/#resume) method * * @since 4.34 */ pause(): void; /** * Generates a localized coordinate string suitable for display given a [Conversion](https://developers.arcgis.com/javascript/latest/references/core/widgets/CoordinateConversion/support/Conversion/) * and a [Point](https://developers.arcgis.com/javascript/latest/references/core/geometry/Point/) * * @param conversion - Specifies the format to use to preview * @param location - The position to preview */ previewConversion(conversion: Conversion, location?: Point): Promise<string | null | undefined>; /** * Resumes the view model's operation. See the [pause()](https://developers.arcgis.com/javascript/latest/references/core/widgets/CoordinateConversion/CoordinateConversionViewModel/#pause) method * * @since 4.34 */ resume(): void; /** * Attempt to convert a string into a [Point](https://developers.arcgis.com/javascript/latest/references/core/geometry/Point/). The format of the * string must be specified. A [Collection](https://developers.arcgis.com/javascript/latest/references/core/core/Collection/) of available formats can be * obtained from the [formats](https://developers.arcgis.com/javascript/latest/references/core/widgets/CoordinateConversion/CoordinateConversionViewModel/#formats) property. * * @param coordinate - The coordinate string. * @param format - Specifies the format of the input coordinate. * @returns When resolved, returns a [Point](https://developers.arcgis.com/javascript/latest/references/core/geometry/Point/). */ reverseConvert(coordinate: string, format: Format): Promise<Point | null | undefined>; /** * Set the view model's new location to the input [Point](https://developers.arcgis.com/javascript/latest/references/core/geometry/Point/) * * @param point - The point to be set as the new location. * @since 4.34 */ setLocation(point: Point | null | undefined): void; /** * Update the input conversions based on the input point. * * @param conversions - An array of [Conversions](https://developers.arcgis.com/javascript/latest/references/core/widgets/CoordinateConversion/support/Conversion/) * to be updated. * @param location - A point that will be used to update each input conversion. * @returns When resolved, returns an array of * [Conversions](https://developers.arcgis.com/javascript/latest/references/core/widgets/CoordinateConversion/support/Conversion/) with updated [Positions](https://developers.arcgis.com/javascript/latest/references/core/widgets/types/#Position). */ updateConversions(conversions: Conversion[], location: Point | null | undefined): Promise<Conversion[]>; } declare const CoordinateConversionViewModelSuperclass: typeof EventedAccessor & typeof GoTo