import type Accessor from "../../../core/Accessor.js"; import type SnappingOptions from "./SnappingOptions.js"; import type TooltipOptions from "./TooltipOptions.js"; import type Units from "../support/Units.js"; import type { SnappingOptionsProperties } from "./SnappingOptions.js"; import type { TooltipOptionsProperties } from "./TooltipOptions.js"; import type { UnitsProperties } from "../support/Units.js"; /** * Properties used to configure [ViewOptions](https://developers.arcgis.com/javascript/latest/references/core/views/interactive/options/ViewOptions/). * * @beta * @since 5.2 */ export interface ViewOptionsProperties { /** * Units for displaying measurements, such as lengths, areas, and volumes. * * Each unit can be configured independently. Unset units use the defaults of the component, view model, or analysis. * A display unit set directly on a component, view model, or analysis overrides the corresponding unit on the view, * without changing the view's options or the units used by other components, view models, or analyses. * * @since 5.2 */ displayUnits?: UnitsProperties; /** * Units for interpreting numeric values entered by the user. * * Input units may differ from [displayUnits](https://developers.arcgis.com/javascript/latest/references/core/views/interactive/options/ViewOptions/#displayUnits). * Each unit can be configured independently. Unset units use the defaults of the component, view model, or analysis. * An input unit set directly on a component, view model, or analysis overrides the corresponding unit on the view, * without changing the view's options or the units used by other components, view models, or analyses. * These options control numeric input in the UI, not the spatial reference or stored coordinates of a geometry. * * @since 5.2 */ inputUnits?: UnitsProperties; /** * Options for snapping to geometry guides and features. * * Snapping is disabled by default in a [MapView](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/) and enabled by default in a * [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/). * * > [!WARNING] * > * > **Known Limitations** * > * > These options currently do not apply to [AreaMeasurementAnalysisView2D](https://developers.arcgis.com/javascript/latest/references/core/views/2d/analysis/AreaMeasurementAnalysisView2D/) or * > [DistanceMeasurementAnalysisView2D](https://developers.arcgis.com/javascript/latest/references/core/views/2d/analysis/DistanceMeasurementAnalysisView2D/), including their measurement components. * > Configure `snappingOptions` on the analysis view or component instead. Tooltip and unit options configured through * > `view.options` still apply. Support for `view.options.snapping` in these analyses and components is planned for a future release. * * @since 5.2 */ snapping?: SnappingOptionsProperties; /** * Options for tooltips shown while sketching, editing, or placing analyses. * * Tooltips are disabled by default in both [MapView](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/) and [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/). * * > [!WARNING] * > * > **Known Limitations** * > * > The [Volume Measurement](https://developers.arcgis.com/javascript/latest/references/core/analysis/VolumeMeasurementAnalysis/) cut-fill elevation tooltip remains enabled * > independently of these options. Its display and input units can still inherit * > [ViewOptions.displayUnits](https://developers.arcgis.com/javascript/latest/references/core/views/interactive/options/ViewOptions/#displayUnits) and [ViewOptions.inputUnits](https://developers.arcgis.com/javascript/latest/references/core/views/interactive/options/ViewOptions/#inputUnits). * * @since 5.2 */ tooltips?: TooltipOptionsProperties; } /** * Configures snapping, tooltips, display units, and input units for supported components, view models, and analyses through [View.options](https://developers.arcgis.com/javascript/latest/references/core/views/View/#options). * * Unlike inherited snapping and tooltip options, display and input units can be overridden individually through * unit properties exposed by a component, view model, or analysis. * For example, setting [DistanceMeasurementAnalysis.unit](https://developers.arcgis.com/javascript/latest/references/core/analysis/DistanceMeasurementAnalysis/#unit) to `feet` overrides * [view.options.displayUnits.length](https://developers.arcgis.com/javascript/latest/references/core/views/interactive/support/Units/#length) for that analysis without changing the view's configuration or other analyses. * Setting the analysis unit back to `null` restores the unit configured through `view.options.displayUnits.length`. * * > [!IMPORTANT] * > * > These options are not saved in a [WebMap](https://developers.arcgis.com/javascript/latest/references/core/WebMap/) or [WebScene](https://developers.arcgis.com/javascript/latest/references/core/WebScene/). * * The following table shows which components, view models, and analyses inherit each option from `view.options`. * * - **✓**: The option is inherited, with explicit component, view model, or analysis **units** taking precedence as described above. * - `Opt-in`: The option is inherited only when the component's or view model's `useViewOptions` property is `true`. * - ✗: The capability exists but does not inherit the option from the view. See the corresponding footnote. * - `N/A`: The capability is unavailable for that component or analysis (for example, Area Measurement 3D does not support tooltips at all). * * | Component or analysis | Inherits `view.options.snapping` | Inherits `view.options.tooltips` | Inherits `view.options.displayUnits` | Inherits `view.options.inputUnits` | * | --- | :---: | :---: | :---: | :---: | * | Area Measurement 2D | ✗¹ | **✓** | **✓** | **✓** | * | Area Measurement 3D | **✓** | N/A | **✓** | N/A | * | Distance Measurement 2D | ✗¹ | **✓** | **✓** | **✓** | * | Direct Line Measurement 3D | **✓** | N/A | **✓** | N/A | * | Elevation Profile | **✓** | N/A | **✓** | N/A | * | Line of Sight | **✓** | **✓** | **✓** | **✓** | * | Viewshed | **✓** | **✓** | **✓** | **✓** | * | Length Dimension | **✓** | N/A | **✓** | N/A | * | Volume Measurement | **✓** | ✗² | **✓** | **✓** | * | Sketch | Opt-in³ | Opt-in³ | Opt-in³ | Opt-in³ | * | Editor | Opt-in³ | Opt-in³ | Opt-in³ | Opt-in³ | * * 1. For 2D measurements, configure snapping through the component's own `snappingOptions`, * [AreaMeasurementAnalysisView2D.snappingOptions](https://developers.arcgis.com/javascript/latest/references/core/views/2d/analysis/AreaMeasurementAnalysisView2D/#snappingOptions), or * [DistanceMeasurementAnalysisView2D.snappingOptions](https://developers.arcgis.com/javascript/latest/references/core/views/2d/analysis/DistanceMeasurementAnalysisView2D/#snappingOptions). * Support for `view.options.snapping` is planned for a future release. * 2. The Volume Measurement cut-fill elevation tooltip remains enabled independently of * `view.options.tooltips`. * 3. For Sketch and Editor, including [SketchViewModel](https://developers.arcgis.com/javascript/latest/references/core/widgets/Sketch/SketchViewModel/) and [EditorViewModel](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/EditorViewModel/), * set the component's or view model's `useViewOptions` property to `true` (default: `false`) to use options on the view. * Changes to this property apply to the next create or update operation, not an operation already in progress. * * When this property is `true`: * * - Snapping and tooltip options specified on the component or view model are preserved but ignored. * - The corresponding controls in the component's Settings menu are hidden. * - Where unit properties are exposed, explicit units override those configured through `view.options` per measurement type. * - Set an explicit unit to `null` or `undefined` to use the unit from `view.options` for that measurement type again. * * @beta * @since 5.2 * @see [Sample - View options for snapping, tooltips and units](https://developers.arcgis.com/javascript/latest/sample-code/view-options/) */ export default class ViewOptions extends Accessor { /** @since 5.2 */ constructor(properties?: ViewOptionsProperties); /** * Units for displaying measurements, such as lengths, areas, and volumes. * * Each unit can be configured independently. Unset units use the defaults of the component, view model, or analysis. * A display unit set directly on a component, view model, or analysis overrides the corresponding unit on the view, * without changing the view's options or the units used by other components, view models, or analyses. * * @since 5.2 */ get displayUnits(): Units; set displayUnits(value: UnitsProperties); /** * Units for interpreting numeric values entered by the user. * * Input units may differ from [displayUnits](https://developers.arcgis.com/javascript/latest/references/core/views/interactive/options/ViewOptions/#displayUnits). * Each unit can be configured independently. Unset units use the defaults of the component, view model, or analysis. * An input unit set directly on a component, view model, or analysis overrides the corresponding unit on the view, * without changing the view's options or the units used by other components, view models, or analyses. * These options control numeric input in the UI, not the spatial reference or stored coordinates of a geometry. * * @since 5.2 */ get inputUnits(): Units; set inputUnits(value: UnitsProperties); /** * Options for snapping to geometry guides and features. * * Snapping is disabled by default in a [MapView](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/) and enabled by default in a * [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/). * * > [!WARNING] * > * > **Known Limitations** * > * > These options currently do not apply to [AreaMeasurementAnalysisView2D](https://developers.arcgis.com/javascript/latest/references/core/views/2d/analysis/AreaMeasurementAnalysisView2D/) or * > [DistanceMeasurementAnalysisView2D](https://developers.arcgis.com/javascript/latest/references/core/views/2d/analysis/DistanceMeasurementAnalysisView2D/), including their measurement components. * > Configure `snappingOptions` on the analysis view or component instead. Tooltip and unit options configured through * > `view.options` still apply. Support for `view.options.snapping` in these analyses and components is planned for a future release. * * @since 5.2 */ get snapping(): SnappingOptions; set snapping(value: SnappingOptionsProperties); /** * Options for tooltips shown while sketching, editing, or placing analyses. * * Tooltips are disabled by default in both [MapView](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/) and [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/). * * > [!WARNING] * > * > **Known Limitations** * > * > The [Volume Measurement](https://developers.arcgis.com/javascript/latest/references/core/analysis/VolumeMeasurementAnalysis/) cut-fill elevation tooltip remains enabled * > independently of these options. Its display and input units can still inherit * > [ViewOptions.displayUnits](https://developers.arcgis.com/javascript/latest/references/core/views/interactive/options/ViewOptions/#displayUnits) and [ViewOptions.inputUnits](https://developers.arcgis.com/javascript/latest/references/core/views/interactive/options/ViewOptions/#inputUnits). * * @since 5.2 */ get tooltips(): TooltipOptions; set tooltips(value: TooltipOptionsProperties); }