import { Mutable } from 'apprt-core/Mutable'; import Extent from '@arcgis/core/geometry/Extent'; import Polygon from '@arcgis/core/geometry/Polygon'; import LOD from '@arcgis/core/layers/support/LOD'; import Camera from '@arcgis/core/Camera'; import Point from '@arcgis/core/geometry/Point'; import SpatialReference from '@arcgis/core/geometry/SpatialReference'; import Layer from '@arcgis/core/layers/Layer'; import Sublayer from '@arcgis/core/layers/support/Sublayer'; import Map from '@arcgis/core/Map'; import TimeExtent from '@arcgis/core/time/TimeExtent'; import Viewpoint from '@arcgis/core/Viewpoint'; import MapView from '@arcgis/core/views/MapView'; import SceneView from '@arcgis/core/views/SceneView'; import { LayerVisibility } from '../api/VisibilityState.js'; import { Navigation, NavigationMembers } from '../api/Navigation.js'; import { AnyLayer } from '../api/BaseTypes.js'; type ViewPadding = __esri.ViewPadding; /** The view mode indicates whether a 2D or a 3D view is active. */ type ViewMode = "2D" | "3D"; /** Viewing mode for 3D apps. */ type ViewingMode = "global" | "local"; /** Represents an active view (2D: MapView, 3D: SceneView) */ type View = MapView | SceneView; /** Environment properties for a SceneView */ type SceneViewEnvironment = __esri.SceneViewEnvironment; /** * The result of a layer lookup. */ interface LayerLookupResult { /** * type 'invalid' if the layerIdPath is invalid. * type 'layer' if the layerIdPath has pointed to a layer, but layer can still be undefined. * type 'sublayer' if the layerIdPath has pointed to a sublayer, but sublayer can still be undefined. */ type: "invalid" | "layer" | "sublayer"; /** * The layer found in the map. */ layer?: Layer; /** * The sublayer found in the map. */ sublayer?: Sublayer; } /** * Documentation for the members of {@link MapWidgetModel}. */ interface MapWidgetModelMembers { /** * The map, it contains the layer structure. * @see [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html) */ get map(): Map; set map(map: Map | __esri.MapProperties); /** * The current view mode. * Possible values are "2D", "3D". * If this state is changed, then the value of the "view" property changes. */ viewmode: ViewMode; /** * Provides access to the current view implementation. * * This value is set by the MapWidget if the viewmode changes. * This value is undefined until the view is initialized by the MapWidget. */ view: View | undefined; /** * The current width of the view. Readonly. * * It's provided for convenience, so that it is not required to watch for "view" changes. * * @see [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#width) */ readonly width: number | undefined; /** * The current height of the view. Readonly. * * It's provided for convenience, so that it is not required to watch for "view" changes. * * @see [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#height) */ readonly height: number | undefined; /** * The current zoom level. * * It's provided for convenience, so that it is not required to watch for "view" changes. * * @see [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#zoom) */ zoom: number | undefined; /** * The map's scale. * * It's provided for convenience, so that it is not required to watch for "view" changes. * * @see [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#scale) */ scale: number | undefined; /** * The map's extent. * * It's provided for convenience, so that it is not required to watch for "view" changes. * * @see [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#extent) */ get extent(): Extent | undefined; set extent(value: Extent | __esri.ExtentProperties | undefined); /** * The map's center point. * * It's provided for convenience, so that it is not required to watch for "view" changes. * * @see [MapView]( https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#center) */ get center(): Point | undefined; set center(value: Point | __esri.PointProperties | undefined); /** * The map's rotation state. * Only available if viewmode is 2D. * * It's provided for convenience, so that it is not required to watch for "view" changes. * * @see [MapView]( https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#rotation) */ rotation: number | undefined; /** * The map's viewpoint. * * It's provided for convenience, so that it is not required to watch for "view" changes. * * @see [MapView]( https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#viewpoint) */ get viewpoint(): Viewpoint | undefined; set viewpoint(value: Viewpoint | __esri.ViewpointProperties | undefined); /** * The scene camera. * Only available if viewmode is 3D. * * It's provided for convenience, so that it is not required to watch for "view" changes. * * @see [SceneView]( https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#camera) */ get camera(): Camera | undefined; set camera(value: Camera | __esri.CameraProperties | undefined); /** * Properties of the environment's visualization in the view. * Only available if viewmode is 3D. * * @see [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#environment) */ get environment(): SceneViewEnvironment | undefined; set environment(value: SceneViewEnvironment | __esri.SceneViewEnvironmentProperties | undefined); /** * Returns the current viewing mode of the view. * Only available if viewmode is 3D. * * @see [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#viewingMode) */ get viewingMode(): ViewingMode | undefined; set viewingMode(value: ViewingMode | undefined); /** * The view's current clipping area. * Only available if viewmode is 3D and if the {@link viewingMode} is `local`. * * @see [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#clippingArea) */ get clippingArea(): Extent | undefined; set clippingArea(value: Extent | __esri.ExtentProperties | undefined); /** * The map's time extent. * * It's provided for convenience, so that it is not required to watch for "view" changes. * * @see [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#timeExtent) */ get timeExtent(): TimeExtent | undefined; set timeExtent(value: TimeExtent | __esri.TimeExtentProperties | undefined); /** * The map's padding. Has to be updated as whole object, single values (left, right, ...) won't trigger View update. */ get padding(): Readonly | undefined; set padding(value: ViewPadding | undefined); /** * If true then data requests are currently pending. * * It's provided for convenience, so that it is not required to watch for "view" changes. * @see [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#updating) */ readonly updating: boolean | undefined; /** * The spatial reference system of the map. * * @see [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#spatialReference) */ get spatialReference(): SpatialReference | undefined; set spatialReference(value: SpatialReference | __esri.SpatialReferenceProperties | undefined); /** * `true`: current state is matching view state. * Check for view.ready and view.viewpoint === model.viewpoint; * and model.viewmode == view.type */ readonly ready: boolean | undefined; /** * Provides access to the first initial extent after initialization. * This property is initialized when the first view is set on the MapWidgetModel. * * It is intended to support "zoom to initial extent" requirements. */ readonly initialExtent: Extent | undefined; /** * Provides access to the first initial view parameter (e.g. extent, zoom etc.) after initialization. * This property is initialized when the first view is set on the MapWidgetModel. * * It is intended to support "restore initial view" requirements. */ readonly initialViewParameters: Record | undefined; /** * Provides access to the first initial viewmode (2D or 3D) after initialization. * This property is initialized when the first view is set on the MapWidgetModel. * * It is intended to support "restore initial view" requirements. */ readonly initialViewMode: ViewMode | undefined; /** * Provides access to the current constraints (2D or 3D). * * Any property changed will result in an update of the corresponding * [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or * [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) * but not the other way around. Changes of the constraints of the view will not be synchronized to this constraints * property. */ get constraints(): Constraints; set constraints(value: Constraints | Partial); /** * Provides access to the current navigation settings. * * All property changes on this object will be applied to the current view and will be reapplied * whenever the current view changes. Property changes done directly on the view will *not* be synchronized * back to this object. */ get navigation(): Navigation; set navigation(value: Navigation | Partial); /** * The map widget model must be destroyed when it is no longer needed. * * NOTE: The lifetime of the default map widget model is managed by map.apps itself. */ destroy(): void; /** * Finds a layer by id in the map. * The layerIdPath is e.g. `` or `/`. * @param layerIdPath The layer id path. */ findLayerInMap(layerIdPath: string | undefined): LayerLookupResult; /** * Returns effective visibility information for the given layer. * * This works by evaluating the current state of the layer _and_ the current state of the view (scale, extent, etc.). * * The layer can be specified as an id or path (e.g. `layerId` or `layerId/sublayerId`) * or as a direct layer reference. */ getLayerVisibility(layerIdPathOrLayer: string | AnyLayer): Promise; /** * Returns `true` if the layer is effectively visible, `false` otherwise. * * This works by evaluating the current state of the layer _and_ the current state of the view (scale, extent, etc.). * * The layer can be specified as an id or path (e.g. `layerId` or `layerId/sublayerId`) * or as a direct layer reference. * * > NOTE: This function is a convenience function around {@link getLayerVisibility}. * > It returns true if (and only if) there are no {@link LayerVisibility.visibilityIssues | visibility issues}. */ isEffectivelyVisible(layerIdPathOrLayer: string | AnyLayer): Promise; /** * Returns the current visibility issues for the given layer. * * This works by evaluating the current state of the layer _and_ the current state of the view (scale, extent, etc.). * * The layer can be specified as an id or path (e.g. `layerId` or `layerId/sublayerId`) * or as a direct layer reference. * * > NOTE: This function should be called within a reactive watch (or effect, etc.). * > Otherwise, it may produce outdated results. */ getLiveLayerVisibility(layerIdPathOrLayer: string | AnyLayer): LayerVisibility | undefined; } /** * The ViewModel of the MapWidget. * It provides access to state information of the MapWidget. * Note: Every MapWidget has it's own MapWidgetModel. * * Use `map-widget.MapWidgetModel` to inject a reference to the main MapWidgetModel. * * See {@link MapWidgetModelMembers} for documentation of members. */ type MapWidgetModel = Mutable; /** * Documentation for instances of {@link Constraints}. */ interface ConstraintsMembers { /** * Indicates whether the user can rotate the map. Only valid for 2D. */ rotationEnabled: boolean; /** * When true, the view snaps to the next LOD when zooming in or out. When false, the zoom is continuous. Only valid * for 2D. */ snapToZoom: boolean; /** * The minimum scale the user is allowed to zoom to within the view. Only valid for 2D. */ minScale: number; /** * The maximum scale the user is allowed to zoom to within the view. Only valid for 2D. */ maxScale: number; /** * The minimum zoom level the user is allowed to zoom to within the view. Only valid for 2D. */ minZoom: number; /** * The maximum zoom level the user is allowed to zoom to within the view. Only valid for 2D. */ maxZoom: number; /** * The area in which the user is allowed to navigate laterally. Only Extent and Polygon geometry types are supported */ geometry: Extent | Polygon | __esri.ExtentProperties | __esri.PolygonProperties | null | undefined; /** * An array of LODs. If not specified, this value is read from the Map. Only valid for 2D. */ lods: (LOD | __esri.LODProperties)[] | null | undefined; /** * Specifies a constraint on the minimum and maximum allowed camera altitude. Only valid for 3D. * * @example * ```ts * constraints.altitude = { * // The minimum allowed camera altitude (in meters). * min: 1000, * // The maximum allowed camera altitude (in meters). * max: 100000 * } * ``` */ altitude: __esri.SceneViewConstraintsAltitudeProperties; /** * Specifies the near and far webgl clip distances. Only valid for 3D. * * @example * ```ts * constraints.clipDistance = { * // The near clip distance. * near: 100, * * // The far clip distance. * far: 1000, * * // Specifies the mode of the constraint which is either auto or manual. * // In auto mode, the near and far clip distance values are automatically determined. * // In manual mode, the near and far clip distance values are user defined. * mode: "manual" * } * ``` */ clipDistance: __esri.SceneViewConstraintsClipDistanceProperties; /** * Specifies a constraint on the amount of allowed tilting of the view. Only valid for 3D. * * @example * ```ts * constraints.tilt = { * // Specifies the maximum amount of tilt (in degrees) allowed in the view and may range from 0.5 to 179.5 * // degrees. * max: 100, * * // Specifies the mode of the constraint. * // There are two possible values: auto or manual. * // In auto mode, the maximum tilt value is automatically determined based on the altitude of the view camera. * // In manual mode, the maximum tilt value is a user defined. * mode: "manual" * } * ``` */ tilt: __esri.SceneViewConstraintsTiltProperties; /** * Query the constraints for a specified viewmode, that are not undefined. * @param viewmode The viewmode to get the constraints for. If empty, "2D" is assumed. * @returns the constraint values */ forViewmode(viewmode?: ViewMode): Record; } /** * A class representing constraints for a view. * It can be queried for the constraints of a specified view mode, that are not undefined * * See {@link ConstraintsMembers} for documentation of members. */ type Constraints = Mutable; export type { Constraints, ConstraintsMembers, LayerLookupResult, MapWidgetModel, MapWidgetModelMembers, SceneViewEnvironment, View, ViewMode, ViewPadding, ViewingMode };