UNPKG

@arcgis/core

Version:

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

194 lines (190 loc) • 9.9 kB
import type DirectLineMeasurementAnalysis from "../../analysis/DirectLineMeasurementAnalysis.js"; import type Accessor from "../../core/Accessor.js"; import type SceneView from "../../views/SceneView.js"; import type { SystemOrLengthUnit } from "../../core/units.js"; import type { MeasurementMode } from "../../views/analysis/types.js"; import type { DirectLineMeasurementAnalysisProperties } from "../../analysis/DirectLineMeasurementAnalysis.js"; /** @deprecated since version 4.33. Use the [Direct Line Measurement 3D component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-direct-line-measurement-3d/) instead. For information on widget deprecation, read about [Esri's move to web components](https://developers.arcgis.com/javascript/latest/components-transition-plan/). */ export interface DirectLineMeasurement3DViewModelProperties extends Partial<Pick<DirectLineMeasurement3DViewModel, "view">> { /** * The direct line measurement analysis object being created or modified by the view model. * * If no analysis is provided, the view model automatically creates its own analysis and adds it to the view. In this * case, the analysis will also be automatically removed from the view when the view model is destroyed. * * @since 4.23 * @example * // Construct a direct line measurement analysis object outside of the view model * const analysis = new DirectLineMeasurementAnalysis({ * startPoint: { * type: "point", // autocasts as new Point() * x: 7.67, * y: 45.981, * z: 3435.765 * }, * endPoint: { * type: "point", * x: 7.659, * y: 45.976, * z: 4437 * } * }); * * // Ensure that the analysis is added to the view * view.analyses.add(analysis); * * // Frame the analysis in the view * view.goTo(analysis.extent); * * // Pass the analysis object as a constructor parameter to modify it using the view model * const viewModel = new DirectLineMeasurement3DViewModel({ * analysis: analysis, * view: view * }); */ analysis?: DirectLineMeasurementAnalysisProperties; /** * Unit system (imperial, metric) or specific unit used for displaying the distance values. * Possible values are listed in [unitOptions](https://developers.arcgis.com/javascript/latest/references/core/widgets/DirectLineMeasurement3D/DirectLineMeasurement3DViewModel/#unitOptions). */ unit?: SystemOrLengthUnit | null; /** * List of unit systems (imperial, metric) and specific units for displaying the distance values. * By default, the following units are included: `metric`, `imperial`, `inches`, `feet`, `us-feet`, `yards`, `miles`, `nautical-miles`, `meters`, `kilometers`. * Possible [unit](https://developers.arcgis.com/javascript/latest/references/core/widgets/DirectLineMeasurement3D/DirectLineMeasurement3DViewModel/#unit) values can only be a subset of this list. */ unitOptions?: SystemOrLengthUnit[] | null; } /** * Provides the logic for the [DirectLineMeasurement3D](https://developers.arcgis.com/javascript/latest/references/core/widgets/DirectLineMeasurement3D/) widget and [component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-direct-line-measurement-3d/). * * @deprecated since version 4.33. Use the [DirectLineMeasurementAnalysis](https://developers.arcgis.com/javascript/latest/references/core/analysis/DirectLineMeasurementAnalysis/) or [Direct Line Measurement 3D component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-direct-line-measurement-3d/) instead. For information on widget deprecation, read about [Esri's move to web components](https://developers.arcgis.com/javascript/latest/components-transition-plan/). * @since 4.7 * @see [DirectLineMeasurement3D](https://developers.arcgis.com/javascript/latest/references/core/widgets/DirectLineMeasurement3D/) widget - _Deprecated since 4.33. Use the [Direct Line Measurement 3D component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-direct-line-measurement-3d/) instead._ * @see [Programming patterns: Widget viewModel pattern](https://developers.arcgis.com/javascript/latest/programming-patterns/#widget-viewmodel-pattern) */ export default class DirectLineMeasurement3DViewModel extends Accessor { constructor(properties?: DirectLineMeasurement3DViewModelProperties); /** * The direct line measurement analysis object being created or modified by the view model. * * If no analysis is provided, the view model automatically creates its own analysis and adds it to the view. In this * case, the analysis will also be automatically removed from the view when the view model is destroyed. * * @since 4.23 * @example * // Construct a direct line measurement analysis object outside of the view model * const analysis = new DirectLineMeasurementAnalysis({ * startPoint: { * type: "point", // autocasts as new Point() * x: 7.67, * y: 45.981, * z: 3435.765 * }, * endPoint: { * type: "point", * x: 7.659, * y: 45.976, * z: 4437 * } * }); * * // Ensure that the analysis is added to the view * view.analyses.add(analysis); * * // Frame the analysis in the view * view.goTo(analysis.extent); * * // Pass the analysis object as a constructor parameter to modify it using the view model * const viewModel = new DirectLineMeasurement3DViewModel({ * analysis: analysis, * view: view * }); */ get analysis(): DirectLineMeasurementAnalysis; set analysis(value: DirectLineMeasurementAnalysisProperties); /** The current measurement calculated between the two points. */ get measurement(): Measurement | null; /** * The view model's state. * * Value | Description * ------------|------------- * disabled | not ready yet * ready | ready for measuring * measuring | currently measuring * measured | measuring has finished * * @default "disabled" */ get state(): "disabled" | "ready" | "measuring" | "measured"; /** * Unit system (imperial, metric) or specific unit used for displaying the distance values. * Possible values are listed in [unitOptions](https://developers.arcgis.com/javascript/latest/references/core/widgets/DirectLineMeasurement3D/DirectLineMeasurement3DViewModel/#unitOptions). */ get unit(): SystemOrLengthUnit; set unit(value: SystemOrLengthUnit | null | undefined); /** * List of unit systems (imperial, metric) and specific units for displaying the distance values. * By default, the following units are included: `metric`, `imperial`, `inches`, `feet`, `us-feet`, `yards`, `miles`, `nautical-miles`, `meters`, `kilometers`. * Possible [unit](https://developers.arcgis.com/javascript/latest/references/core/widgets/DirectLineMeasurement3D/DirectLineMeasurement3DViewModel/#unit) values can only be a subset of this list. */ get unitOptions(): SystemOrLengthUnit[]; set unitOptions(value: SystemOrLengthUnit[] | null | undefined); /** The view from which the widget will operate. */ view?: SceneView | null; /** * Clears the current measurement. * * @since 4.16 */ clear(): void; /** * Starts a new measurement. * * @since 4.16 * @example * const directLineMeasurement3D = new DirectLineMeasurement3D({ * view: view, * unit: "kilometers" * }); * * await directLineMeasurement3D.start(); */ start(): Promise<void>; } /** * Measurement value. * * @deprecated since version 4.33. Use the [Direct Line Measurement 3D component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-direct-line-measurement-3d/) instead. For information on widget deprecation, read about [Esri's move to web components](https://developers.arcgis.com/javascript/latest/components-transition-plan/). */ export interface MeasurementValue { /** Textual representation of the measured value. */ readonly text: string | null; /** * State of the measured value. * * Value | Description * ------------|------------- * available | measured value is available * unavailable | measured value is not available due an incomplete measurement or because the value is not available for the given measurement configuration (e.g. direct distance is unavailable in `geodesic` mode) */ readonly state: "available" | "unavailable"; } /** @deprecated since version 4.33. Use the [Direct Line Measurement 3D component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-direct-line-measurement-3d/) instead. For information on widget deprecation, read about [Esri's move to web components](https://developers.arcgis.com/javascript/latest/components-transition-plan/). */ export interface Measurement { /** * Describes how the `horizontalDistance` is computed. * - In `euclidean` mode, the horizontal distance is the 2D distance between the two points, computed in a Euclidean manner. * This mode is used in scenes with projected coordinate systems (PCS), apart from Web Mercator. * - In `geodesic` mode, the horizontal distance is computed geodetically. * This mode is used in scenes with geographic coordinate systems (GCS) and in Web Mercator. */ readonly mode: MeasurementMode; /** The 3D distance between the two points that is computed in a Euclidean manner. It is only available for distances below 100 kilometers. */ readonly directDistance: MeasurementValue; /** Horizontal distance between the two points. */ readonly horizontalDistance: MeasurementValue; /** The elevation difference between the two points. */ readonly verticalDistance: MeasurementValue; }