import View2D from "@arcgis/core/views/View2D.js";
            const View2D = await $arcgis.import("@arcgis/core/views/View2D.js");
            @arcgis/core/views/View2D
        View2D is the base class for all 2D views. To construct 2D views see MapView and LinkChartView.
- See also
 
Property Overview
| Name | Type | Summary | Class | 
|---|---|---|---|
Collection containing a flat list of all the created LayerViews related to the basemap, operational layers, and group layers in this view.  | View | ||
A collection of analyses associated with the view.  | View2D | ||
Represents an ongoing view animation initialized by goTo().  | View2D | ||
Indicates whether animations are enabled in the view.  | View2D | ||
The ARIA attributes for the view container.  | View2D | ||
The background color of the MapView.  | View2D | ||
Represents the view for a single basemap after it has been added to the map.  | View | ||
A convenience property used for defining the breakpoints on the height and width of the view.  | View2D | ||
Represents the view's center point; when setting the center, you may pass a Point instance or an array of numbers representing a longitude/latitude pair (  | View2D | ||
Specifies constraints to scale, zoom, and rotation that may be applied to the MapView.  | View2D | ||
The   | View2D | ||
The name of the class.  | Accessor | ||
Indicates whether displayFilters are honored across all layers in the view.  | View | ||
The extent represents the visible portion of a map within the view as an instance of Extent.  | View2D | ||
A fatal error returned when the view loses its WebGL context.  | View | ||
Applies a display filter on the view for a specific set of floor levels.  | View2D | ||
Indicates if the browser focus is on the view.  | View2D | ||
Allows for adding graphics directly to the default graphics in the View.  | View | ||
The height of the view in pixels read from the view container element.  | View2D | ||
A convenience property indicating the general size of the view's height.  | View2D | ||
Options for configuring the highlight.  | View2D | ||
Represents a collection of HighlightOptions objects which can be used to highlight features throughout an application.  | View | ||
Options to configure input handling of the View.  | View | ||
Indication whether the view is being interacted with (for example when panning or by an interactive tool).  | View | ||
A collection containing a hierarchical list of all the created LayerViews of the operational layers in the map.  | View | ||
The magnifier allows for showing a portion of the view as a magnifier image on top of the view.  | View | ||
An instance of a Map object to display in the view.  | View | ||
Indication whether the view is being navigated (for example when panning).  | View | ||
Options to configure the navigation behavior of the View.  | View | ||
A convenience property indicating the view's orientation.  | View2D | ||
Use the padding property to make the center, and extent, etc.  | View | ||
A Popup object that displays general content or attributes from layers in the map.  | View2D | ||
Controls whether the popup opens when users click on the view.  | View2D | ||
When   | View | ||
Provides more granular information about the view's process of becoming ready.  | View | ||
Defines which anchor stays still while resizing the browser window.  | View2D | ||
Indicates if the view is being resized.  | View2D | ||
Represents the size of one pixel in map units.  | View2D | ||
The clockwise rotation of due north in relation to the top of the view in degrees.  | View2D | ||
Represents the map scale at the center of the view.  | View2D | ||
An array containing the width and height of the view in pixels, e.g.  | View2D | ||
The spatial reference of the view.  | View2D | ||
Indicates if the MapView's spatialReference can be changed after it is ready.  | View2D | ||
Indication whether the view is animating, being navigated with or resizing.  | View | ||
Indicates if the view is visible on the page.  | View2D | ||
This property specifies the base colors used by some widgets and components to render graphics and labels.  | View | ||
The tiling scheme information of the view.  | View2D | ||
The view's time extent.  | View | ||
Defines the time zone of the view.  | View2D | ||
The dimension of the view.  | View2D | ||
Exposes the default widgets available in the view and allows you to toggle them on and off.  | View2D | ||
Indicates whether the view is being updated by additional data requests to the network, or by processing received data.  | View | ||
Represents the current view as a Viewpoint or point of observation on the view.  | View2D | ||
The visibleArea represents the visible portion of a map within the view as an instance of a Polygon.  | View2D | ||
The width of the view in pixels read from the view container element.  | View2D | ||
A convenience property indicating the general size of the view's width.  | View2D | ||
Represents the level of detail (LOD) at the center of the view.  | View2D | 
Property Details
- 
  
  
allLayerViews
InheritedPropertyallLayerViews Collection<LayerView>readonlyInherited from View - 
  
    
Collection containing a flat list of all the created LayerViews related to the basemap, operational layers, and group layers in this view.
- See also
 
 
- 
  
  
analyses
Propertyanalyses Collection<Analysis>autocastSince: ArcGIS Maps SDK for JavaScript 4.34View2D since 4.31, analyses added at 4.34.  - 
  
    
A collection of analyses associated with the view.
Examples// Adds an analysis to the View view.analyses.add(elevationProfileAnalysis);// Removes an analysis from the View view.analyses.remove(elevationProfileAnalysis); 
- 
  
  
animation
Propertyanimation ViewAnimation |null |undefined - 
  
    
Represents an ongoing view animation initialized by goTo(). You may watch this property to be notified of the animation's state.
- See also
 
ExamplereactiveUtils.watch( () => view.animation, (response) => { if(response?.state === "running"){ console.log("Animation in progress"); } else{ console.log("No animation"); } } ); 
- 
  
  
animationsEnabled
PropertyanimationsEnabled BooleanSince: ArcGIS Maps SDK for JavaScript 4.34View2D since 4.31, animationsEnabled added at 4.34.  - 
  
    
Indicates whether animations are enabled in the view. This includes animated symbols (animated CIMSymbol, PictureMarkerSymbol from a GIF/animated PNG), animated renderers (FlowRenderer), animated layers (MediaLayer, VideoLayer), and animations triggered by view navigation (for example, goTo()). Setting this property to
falsedisables all animations in the view.- Default Value:true
 
 
- 
  
  
  
  
  
  
  
    
Since: ArcGIS Maps SDK for JavaScript 4.34View2D since 4.31, aria added at 4.34.  - 
  
    
The ARIA attributes for the view container.
- Properties
 - 
  optionaldescribedByElements HTMLElement[]
The array of HTML elements that describe the view container.
optionaldescription StringThe
aria-descriptionof the view container.optionallabel StringThe
aria-labelof the view container.optionallabelledByElements HTMLElement[]The array of HTML elements that label the view container.
 - See also
 
 
- 
  
  
background
Propertybackground ColorBackground |null |undefinedautocast - 
  
    
The background color of the MapView. If the view's map changes, the view's
backgroundis reset to the map's background, even if the user set it previously.- Default Value:null
 
Examplelet view = new MapView({ container: "viewDiv", map: map, background: { // autocasts new ColorBackground() color: "magenta" // autocasts as new Color() } }); 
- 
  
  
basemapView
InheritedPropertybasemapView BasemapViewInherited from View - 
  
    
Represents the view for a single basemap after it has been added to the map.
 
- 
  
  
breakpoints
Propertybreakpoints Object - 
  
    
A convenience property used for defining the breakpoints on the height and width of the view. The sizes specified here determine the values of the widthBreakpoint and heightBreakpoint properties depending on the view's size.
Setting up breakpoints can aid in responsive app design. It does this by watching width and height breakpoints. This is helpful as it removes the need for multiple
@mediacalls. Instead of listening for the view's size and/or resizes property, you can set up a watch handler for either the widthBreakpoint or heightBreakpoint properties of the view.Please refer to the styling guide for additional information on working with this.
- Properties
 - 
  optionalxsmall NumberDefault Value:544
Sets the
xsmallbreakpoint in pixels used by widthBreakpoint and heightBreakpoint. If the view's height or width is smaller than this value, then the value of widthBreakpoint or heightBreakpoint will bexsmall.optionalsmall NumberDefault Value:768Sets the
smallbreakpoint in pixels used by widthBreakpoint and heightBreakpoint. If the view's height or width is between this value and the value of thexsmallproperty, then the value of widthBreakpoint or heightBreakpoint will besmall.optionalmedium NumberDefault Value:992Sets the
mediumbreakpoint in pixels used by widthBreakpoint and heightBreakpoint. If the view's height or width is between this value and the value of thesmallproperty, then the value of widthBreakpoint or heightBreakpoint will bemedium.optionallarge NumberDefault Value:1200Sets the
largebreakpoint in pixels used by widthBreakpoint and heightBreakpoint. If the view's height or width is between this value and the value of themediumproperty, then the value of widthBreakpoint or heightBreakpoint will belarge. widthBreakpoint and heightBreakpoint. If the view's height or width is greater than the value of thelargeproperty, then the value of widthBreakpoint or heightBreakpoint will bexlarge. - See also
 
Example// Instead of watching the size or resizing properties reactiveUtils.watch(() => view.size, () => {}); reactiveUtils.watch(() => view.resizing, () => {}); // Set up a watch handle for breakpoint reactiveUtils.watch( () => view.widthBreakpoint, (breakpoint) => { switch (breakpoint) { case "xsmall": // do something break; case "small": case "medium": case "large": case "xlarge": // do something else break; default: } } ); 
- 
  
    
Represents the view's center point; when setting the center, you may pass a Point instance or an array of numbers representing a longitude/latitude pair (
[-100.4593, 36.9014]). Setting the center immediately changes the current view. For animating the view, see goTo().The returned Point object is always in the spatial reference of the view and may be modified internally. To persist the returned object, create a clone using Point.clone().
Notes
- If the spatial reference of 
centerset in the constructor does not match the spatialReference of the view, then projectOperator will be loaded dynamically. - At runtime, the projectOperator must be loaded when
setting the 
centerto a spatial reference that doesn't match the view spatial reference. You can check if the projectOperator is loaded prior to setting the center by calling projectOperator.isLoaded(). If it is not yet loaded, you can call projectOperator.load(). 
- See also
 
Examples// Sets the initial center point of the view to lon/lat coordinates // lon/lat will be projected to match the spatial reference of the view let view = new MapView({ center: [-112, 38] });// Updates the view's center point to a pre-determined Point object let pt = new Point({ x: 12804.24, y: -1894032.09, spatialReference: { wkid: view.spatialReference // wkid 2027 } }); view.center = pt;const centerPoint = new Point({ x: -8746995, y: 4352308, spatialReference: { wkid: 8857 } }); if (!projectOperator.isLoaded()) { await projectOperator.load(); } view.center = centerPoint; - If the spatial reference of 
 
- 
  
    
Specifies constraints to scale, zoom, and rotation that may be applied to the MapView. The
constraints.lodsshould be set in the MapView constructor, if the map does not have a basemap or when the basemap does not have tileInfo. See Zoom and LODs section to learn more how MapView's zoom and LODs work. See the object specification below.- Properties
 - 
  
An array of LODs. If not specified, this value is read from the Map. It is possible to generate additional LODs via the TileInfo.create() method. This is useful in cases where the default amount of LODs provided are not sufficient. One example of when this is needed is when setting the view scale 1:1. Additionally, this property may be autocast.
The area in which the user is allowed to navigate laterally. Only Extent and Polygon geometry types are supported. Z-values are ignored. This property is honored by interactive MapView navigation and goTo(). This property may be autocast.
minScale NumberThe minimum scale the user is allowed to zoom to within the view.
maxScale NumberThe maximum scale the user is allowed to zoom to within the view. Setting this value to
0allows the user to overzoom layer tiles.minZoom NumberThe minimum zoom level the user is allowed to zoom to within the view.
maxZoom NumberThe maximum zoom level the user is allowed to zoom to within the view. Setting this value to
0allows the user to over-zoom layer tiles.snapToZoom BooleanDefault Value:trueWhen
true, the view snaps to the next LOD when zooming in or out. Whenfalse, the zoom is continuous. This does not apply when zooming in/out using two finger pinch in/out.rotationEnabled BooleanDefault Value:trueIndicates whether the user can rotate the map.
A read-only property that specifies the levels of detail (LODs) read from the Map.
effectiveMinZoom NumberA read-only property that specifies the minimum zoom level the user is allowed to zoom to within the view.
effectiveMaxZoom NumberA read-only property that specifies the maximum zoom level the user is allowed to zoom to within the view.
effectiveMinScale NumberA read-only property that specifies the minimum scale the user is allowed to zoom to within the view.
effectiveMaxScale NumberA read-only property that specifies the maximum scale the user is allowed to zoom to within the view.
 - See also
 
Examplesview.constraints = { geometry: { // Constrain lateral movement to Lower Manhattan type: "extent", xmin: -74.020, ymin: 40.700, xmax: -73.971, ymax: 40.73 }, minScale: 500000, // User cannot zoom out beyond a scale of 1:500,000 maxScale: 0, // User can overzoom tiles rotationEnabled: false // Disables map rotation };// This snippet shows how to set the MapView scale 1:1 while generating additional LODs for the MapView.constraints. const spatialReference = new SpatialReference({ wkid: 2154 }); const center = new Point({ x: 0, y: 0, spatialReference }); // Create LODs from level 0 to 31 const tileInfo = TileInfo.create({ spatialReference, numLODs: 32 }); const lods = tileInfo.lods; let view = new MapView({ container: "viewDiv", map, scale: 1, center, spatialReference, constraints: { lods: lods, snapToZoom: false } }); 
- 
  
  
container
Propertycontainer HTMLDivElement |null |undefinedautocastAutocasts from String - 
  
    
The
idor node representing the DOM element containing the view. This is typically set in the view's constructor.Examples// Sets container to the DOM id let view = new MapView({ container: "viewDiv" // ID of the HTML element that holds the view });// Sets container to the node let viewNode = document.getElementById("viewDiv"); let view = new SceneView({ container: viewNode }); 
- 
  
  
displayFilterEnabled
InheritedPropertydisplayFilterEnabled BooleanInherited from ViewSince: ArcGIS Maps SDK for JavaScript 4.32View since 4.0, displayFilterEnabled added at 4.32.  - 
  
    
Indicates whether displayFilters are honored across all layers in the view. If
false, display filters are ignored on all layers and all features are rendered. To ignore display filters on a per-layer basis, set the layer's displayFilterEnabled property tofalse.- Default Value:true
 
 
- 
  
    
The extent represents the visible portion of a map within the view as an instance of Extent. Setting the extent immediately changes the view without animation. To animate the view, see goTo(). When the view is rotated, the extent does not update to include the newly visible portions of the map.
The returned Extent object is an internal reference which may be modified internally. To persist the returned object, create a copy using Extent.clone().
Notes
- If the spatial reference of 
extentset in the constructor does not match the spatialReference of the view, then projectOperator will be loaded dynamically. - At runtime, the projectOperator must be loaded when
setting the 
extentto a spatial reference that doesn't match the view spatial reference. You can check if the projectOperator is loaded prior to setting the extent by calling projectOperator.isLoaded(). If it is not yet loaded, you can call projectOperator.load(). 
- Default Value:null
 - See also
 
Example// the projectOperator must be loaded in the app if the spatial reference // of the view does not match the spatial reference of the extent const extent = new Extent({ xmin: -13056650, ymin: 6077558, xmax: -13055709, ymax: 6077938, spatialReference: new SpatialReference({wkid:3857}) }); view.extent = extent; // Updates the view without animation - If the spatial reference of 
 
- 
  
  
  
  Inherited from View
 - 
  
    
A fatal error returned when the view loses its WebGL context. Watch this property to properly handle the error and attempt to recover the WebGL context.
- See also
 
ExamplereactiveUtils.when( () => view.fatalError, () => { console.error("Fatal Error! View has lost its WebGL context. Attempting to recover..."); view.tryFatalErrorRecovery(); } ); 
- 
  
  
floors
Propertyfloors Collection<string>autocast - 
  
    
Applies a display filter on the view for a specific set of floor levels. It can filter the map display on floor-aware layers by zero or more level IDs.
 
- 
  
  
focused
Propertyfocused Booleanreadonly - 
  
    
Indicates if the browser focus is on the view.
 
- 
  
  
graphics
InheritedPropertygraphics Collection<Graphic>autocastInherited from View - 
  
    
Allows for adding graphics directly to the default graphics in the View.
- See also
 
Examples// Adds a graphic to the View view.graphics.add(pointGraphic);// Removes a graphic from the View view.graphics.remove(pointGraphic); 
- 
  
  
height
Propertyheight Numberreadonly - 
  
    
The height of the view in pixels read from the view container element.
The view container needs to have a height greater than 0 to be displayed.
- Default Value:0
 
 
- 
  
  
heightBreakpoint
PropertyheightBreakpoint String - 
  
    
A convenience property indicating the general size of the view's height. This value is determined based on where the view's height falls in the ranges defined in the breakpoints property. See the table below for a list of possible values. Use the breakpoints property to override the default thresholds.
Please refer to the styling guide for additional information on working with this.
Possible Value Description Default thresholds (pixels) xsmall The height of the view is smaller than the value set in the xsmallbreakpoint.< 545 small The height of the view is between the values set in the xsmallandsmallbreakpoints.545 - 768 medium The height of the view is between the values set in the smallandmediumbreakpoints.769 - 992 large The height of the view is between the values set in the mediumandlargebreakpoints.993 - 1200 xlarge The height of the view is larger than the value set in the largebreakpoint.> 1200 Possible Values:"xsmall" |"small" |"medium" |"large" |"xlarge"
ExamplereactiveUtils.watch( () => view.heightBreakpoint === "xsmall", () => { // clear the view's default UI components if // the app is used on a mobile device view.ui.components = []; } ); 
- 
  
  
highlightOptions
PropertyhighlightOptions HighlightOptionsautocastDeprecated since version 4.32. Use the highlights property instead. - 
  
    
Options for configuring the highlight. Use the highlight method on the appropriate LayerView to highlight a feature.
Exampleconst view = new MapView({ map: map, highlightOptions: { color: [255, 255, 0, 1], haloOpacity: 0.9, fillOpacity: 0.2 } }); 
- 
  
  
highlights
InheritedPropertyhighlights Collection<HighlightOptions>autocastInherited from ViewSince: ArcGIS Maps SDK for JavaScript 4.32View since 4.0, highlights added at 4.32.  - 
  
    
Represents a collection of HighlightOptions objects which can be used to highlight features throughout an application. Highlighting works by applying highlight options to one or more features. You can configure these options (such as color or opacity) to define how a feature will be visually emphasized.
A maximum of six HighlightOptions objects are supported in the collection, and they can be added, removed, and reordered freely. Their order in the collection determines priority, with the last object having the highest priority. If you apply more than one highlight to a feature, the one that is last within the collection will be applied. The HighlightOptions object must be part of this collection in order to be applied to features.
To highlight a feature, use the highlight() method on the relevant LayerView instance. To apply specific HighlightOptions, include the name in the
highlight()method'soptionsparameter. If nonameis provided, the feature will use thedefaulthighlight options.The table below shows the default highlight options in the View's highlights collection if the collection has not been modified:
Highlight options name Description Default settings default The default highlight options. Used when layerView.highlight()is called without specifying any particular highlight options.{ name: "default", color: "cyan", haloOpacity: 1, fillOpacity: 0.25, shadowColor: "black", shadowOpacity: 0.4, shadowDifference: 0.2}temporary The temporary highlight options, pre-configured for common use cases such as hovering over a feature in the view. { name: "temporary", color: "yellow", haloOpacity: 1, fillOpacity: 0.25, shadowColor: "black", shadowOpacity: 0.4, shadowDifference: 0.2 }Examples// Use the default highlights collection to apply a highlight to features when you hover over them // A handler can be used to remove any previous highlight when applying a new one let hoverHighlight; view.on("pointer-move", (event) => { // Search for the first feature in the featureLayer at the hovered location view.hitTest(event, { include: featureLayer }).then((response) => { if (response.results[0]) { const graphic = response.results[0].graphic; view.whenLayerView(graphic.layer).then((layerView) => { // Remove any previous highlight, if it exists hoverHighlight?.remove(); // Highlight the hit features with the temporary highlight options, which are pre-configured for this use case hoverHighlight = layerView.highlight(graphic, { name: "temporary"}); }); } }); });// Override the default highlights collection const view = new MapView({ map: map, container: "viewDiv", // Set the highlight options to be used in the view highlights: [ { name: "default", color: "orange" }, { name: "temporary", color: "magenta" }, { name: "table", color: "cyan", fillOpacity: 0.5, haloOpacity: 0} ] });// Add highlight options to the collection after initialization const selectionHighlightOptions = { name: "selection", color: "#ff00ff", // bright fuchsia haloOpacity: 0.8, fillOpacity: 0.2 }; // Add the options to the highlights collection at the first position view.highlights.add(selectionGroup, 0); 
- 
  
  
layerViews
InheritedPropertylayerViews Collection<LayerView>readonlyInherited from View - 
  
    
A collection containing a hierarchical list of all the created LayerViews of the operational layers in the map.
- See also
 
 
- 
  
  
  
  Inherited from View
 - 
  
    
An instance of a Map object to display in the view. A view may only display one map at a time. On the other hand, one Map may be viewed by multiple MapViews and/or SceneViews simultaneously.
This property is typically set in the constructor of the MapView or SceneView. See the class description for examples demonstrating the relationship between the map and the view.
 
- 
  
  
navigation
InheritedPropertynavigation NavigationautocastInherited from View - 
  
    
Options to configure the navigation behavior of the View.
Example// Disable the gamepad usage, single touch panning, panning momentum and mouse wheel zooming. const view = new MapView({ container: "viewDiv", map: new Map({ basemap: "satellite" }), center: [176.185, -37.643], zoom: 13, navigation: { gamepad: { enabled: false }, actionMap: { dragSecondary: "none", // Disable rotating the view with the right mouse button mouseWheel: "none" // Disable zooming with the mouse wheel }, browserTouchPanEnabled: false, momentumEnabled: false, } }); 
- 
  
  
orientation
Propertyorientation Stringreadonly - 
  
    
A convenience property indicating the view's orientation. See the table below for a list of possible values.
Please refer to the styling guide for additional information on working with this.
Possible Values:"landscape" |"portrait"
 
- 
  
    
A Popup object that displays general content or attributes from layers in the map.
By default, the
popupproperty is an empty object that allows you to set the popup options. A Popup instance is automatically created and assigned to the view's popup when the user clicks on the view and popupEnabled istrue, when the openPopup() method is called, or when some widgets need the popup, such as Search. If popup isnull, the popup instance will not be created.- See also
 
Examples// Set the view's popup to a new Popup instance. // The popup will show anytime a popup is called such as when selecting features or displaying a Search result. view.popup = new Popup();// Set the popup to a PopupOptions object with popup properties set such as the dock options. // The popup will show anytime a popup is called. view.popup = { dockEnabled: true, dockOptions: { position: "top-left", breakpoint: false } };// Set the popup to null. This disables the popup so it will never show up. view.popup = null; 
- 
  
  
popupEnabled
PropertypopupEnabled Boolean - 
  
    
Controls whether the popup opens when users click on the view.
When
true, a Popup instance is created and assigned to view.popup the first time the user clicks on the view, unless popup isnull. The popup then processes the click event.When
false, the click event is ignored and popup is not created for features but will open for other scenarios that use a popup, such as displaying Search results.Example// Disable the popup from automatically appearing and // open the popup manually using a click event. view.popupEnabled = false; view.on("click", (event)=> { view.openPopup({ // Set properties for the manually opened popup ... }); }); 
- 
  
  
ready
InheritedPropertyready BooleanreadonlyInherited from View - 
  
    
When
true, this property indicates whether the view successfully satisfied all dependencies, signaling that the following conditions are met.- The view has a map. If map is a WebMap or a WebScene, then the map or scene must be loaded.
 - The view has a container with a size greater than 
0. - The view has a spatialReference, a center, and a scale. These also can be inferred by setting an extent.
 
When a view becomes ready it will resolve itself and invoke the callback defined in when() where code can execute on a working view. Subsequent changes to a view's readiness would typically be handled by watching
view.readyand providing logic for cases where the map or container change.- Default Value:false
 - See also
 
 
- 
  
  
readyState
InheritedPropertyreadyState StringreadonlyInherited from ViewSince: ArcGIS Maps SDK for JavaScript 4.32View since 4.0, readyState added at 4.32.  - 
  
    
Provides more granular information about the view's process of becoming ready. This property helps manage view properties when the view fails to become ready, such as when the basemap fails to load.
The following are the possible expected values and their descriptions:
Value Description loadingThe view is currently loading information from the map. readyThe view is ready. This is similar to the readyproperty.missing-mapThe view is missing a map. Set the view's map property. missing-containerThe view is missing a container. Set the view's container property. empty-mapThe view's map has no layers. Add layers to the map. rendering-errorThe view failed to render. This is similar to the fatalErrorproperty.map-content-errorThe view failed to find information from the map and couldn't derive the spatialReference. Verify that the mapcorrectly loaded with theloadErrorproperty, as well as its basemap, and the first layer in the map's layers collection. Alternatively, set a validcenter,scale, andspatialReference.Possible Values:"loading" |"missing-map" |"missing-container" |"empty-map" |"map-content-error" |"rendering-error" |"ready"
- Default Value:"loading"
 
Examples// Watch the view's readyState immediately after its initialization. reactiveUtils.watch( () => view.readyState, (state) => { switch (state) { case "missing-map": // Map is missing. Set a default map. view.map = new Map({ basemap: "streets" }); break; } }, { initial: true // fire the callback immediately after initialization. } );const view = new MapView({ container: "viewDiv", map: new Map({ basemap: { baseLayers: [ new TileLayer({ url: "my-failing-tiled-service" }) ] } }); reactiveUtils.watch(() => view.readyState, (state) => { switch (state) { case "map-content-error": // Defaults to a different map in case of failure view.map = new Map({ basemap: "streets" }); break; case "rendering-error": view.tryFatalErrorRecovery(); break; default: console.log("View is not ready:", state); } }); 
- 
  
  
resizeAlign
PropertyresizeAlign String - 
  
    
Defines which anchor stays still while resizing the browser window. The default,
center, ensures the view's center point remains constantly visible as the window size changes. The other options allow the respective portion of the view to remain visible when the window's size is changed.Possible Values:"center" |"left" |"right" |"top" |"bottom" |"top-left" |"top-right" |"bottom-left" |"bottom-right"
- Default Value:"center"
 
 
- 
  
  
resizing
Propertyresizing Booleanreadonly - 
  
    
Indicates if the view is being resized.
- Default Value:false
 
 
- 
  
  
resolution
Propertyresolution Numberreadonly - 
  
    
Represents the size of one pixel in map units. The value of resolution can be found by dividing the extent width by the view's width.
 
- 
  
  
rotation
Propertyrotation Number - 
  
    
The clockwise rotation of due north in relation to the top of the view in degrees. The view may be rotated by directly setting the rotation or by using the following mouse event:
Right-click + Drag. Map rotation may be disabled by setting therotationEnabledproperty in constraints tofalse. See the code snippet below for an example of this.- Default Value:0
 
Examples// Due north is rotated 90 degrees, pointing to the right side of the view view.rotation = 90;// Due north is rotated 180 degrees, pointing to the bottom of the view view.rotation = 180;// Due north is rotated 270 degrees, pointing to the left side of the view view.rotation = 270;// Due north is rotated 0 degrees, pointing to the top of the view (the default) view.rotation = 0; // 360 or multiple of 360 (e.g. 720) works here as well.// Disables map rotation view.constraints = { rotationEnabled: false }; 
- 
  
    
An array containing the width and height of the view in pixels, e.g.
[width, height]. 
- 
  
  
spatialReference
PropertyspatialReference SpatialReferenceautocast - 
  
    
The spatial reference of the view. This indicates the projected or geographic coordinate system used to locate geographic features in the map. Starting at version 4.23, you can change the spatialReference of the MapView after it is initialized by either directly changing this property, or by changing the basemap from the BasemapGallery or BasemapToggle widgets. Set spatialReferenceLocked property to
trueto prevent users from changing the view's spatial reference at runtime.Prior to changing the spatial reference, check if the projectOperator is loaded by calling projectOperator.isLoaded(). If it is not yet loaded, call projectOperator.load() method. If the projectOperator is not loaded, the view's center will default to
[0, 0]in the new spatial reference of the view and a console error will be thrown.Notes
- 
LayerViews not compatible with the view's spatial reference are not displayed. In such case, the layer view's suspended property is
trueand spatialReferenceSupported property isfalse. - 
When setting view's spatial reference, the center, extent or viewpoint.targetGeometry properties are projected to the new spatial reference. The scale and rotation properties are adjusted to keep the content of the map at the same size and orientation on screen.
 - 
To ensure TileLayers and VectorTileLayers are displayed in a basemap correctly, the spatialReference of the MapView must be set match their tileInfo's spatial reference.
 - 
Switching spatial reference with an imageCoordinateSystem is not supported.
 
- Default Value:null
 - See also
 
Examples// check if the projectOperator is loaded if (!projectOperator.isLoaded()) { projectOperator.load().then(() => { // change the spatial reference of the view to equal earth projection view.spatialReference = new SpatialReference({ wkid: 54035 //equal earth projection }); }); } else { // the projectOperator is already loaded. // change the spatial reference of the view to equal earth projection view.spatialReference = new SpatialReference({ wkid: 54035 //equal earth projection }); }const basemap = await changeBasemap(); const spatialReference = await findSpatialReference(basemap); // check if basemap has the same spatial reference as the view if they are not equal // then check if the projectOperator is loaded. load the projectOperator if it is not loaded. // If loaded, then simply change view.spatialReference to match the basemap spatialReference if (spatialReference && !view.spatialReference.equals(spatialReference)) { if (!projectOperator.isLoaded()) { await projectOperator.load(); } view.spatialReference = spatialReference; } // change the basemap map.basemap = basemap; async function changeBasemap() { let basemap; if (map.basemap.title === "OpenStreetMap Vector Basemap (Blueprint - WGS84)"){ basemap = new Basemap({ portalItem: { // Spilhaus - one ocean basemap id: "5639ccf22d4c4830ab815c4f9c9319bb" } }); } else { basemap = osm84; } return basemap; } async function findSpatialReference(basemap) { await basemap.load(); if (basemap.spatialReference) { return basemap.spatialReference; } const layer = basemap.baseLayers.at(0); if (!layer) { return null; } await layer.load(); return layer.spatialReference; } - 
 
- 
  
  
spatialReferenceLocked
PropertyspatialReferenceLocked Boolean - 
  
    
Indicates if the MapView's spatialReference can be changed after it is ready. The default is
falseindicating the view's spatialReference can be changed at runtime. Whentrue, basemaps with spatial references that do not match the MapView's spatial reference will be disabled in BasemapGallery and BasemapToggle widgets and the view spatialReference cannot be changed at runtime.- Default Value:false
 - See also
 
 
- 
  
  
suspended
Propertysuspended Booleanreadonly - 
  
    
Indicates if the view is visible on the page. When
true, the view is not visible and it stops rendering and updating data. Set totruewhen one of the following conditions are met:- if the view does not have a container,
 - if the view's height or width equal to 0,
 - if the view container's css style 
displayis set tonone(display:none). 
When the view container's css style
visibilityis set tohidden, this property is set tofalse, and the view is hidden but it stills renders and updates data.- Default Value:true
 
 
- 
  
  
  
  Inherited from View
 - 
  
    
This property specifies the base colors used by some widgets and components to render graphics and labels. This only affects those components that would otherwise use the default orange pattern.
- Default Value:null
 - See also
 
Example// Update the theme to use purple graphics // and slightly transparent green text view.theme = new Theme({ accentColor: "purple", textColor: [125, 255, 13, 0.9] }); 
- 
  
    
The tiling scheme information of the view.
 
- 
  
  
timeExtent
InheritedPropertytimeExtent TimeExtent |null |undefinedautocastInherited from View - 
  
    
The view's time extent. Time-aware layers display their temporal data that falls within the view's time extent. Setting the view's time extent is similar to setting the spatial extent because once the time extent is set, the view updates automatically to conform to the change.
- Default Value:null
 
Example// Create a csv layer from an online spreadsheet. let csvLayer = new CSVLayer({ url: "http://test.com/daily-magazines-sold-in-new-york.csv", timeInfo: { startField: "SaleDate" // The csv field contains date information. } }); // Create a mapview showing sales for the last week of March 2019 only. const view = new MapView({ map: map, container: "viewDiv", timeExtent: { start: new Date("2019, 2, 24"), end: new Date("2019, 2, 31") } }); 
- 
  
  
timeZone
PropertytimeZone String - 
  
    
Defines the time zone of the view. The time zone property determines how dates and times are represented to the user, but the underlying data is unchanged. Changing the time zone will have the following effect:
- Arcade: Arcade expressions referencing date values in labels, renderers, and forms
will represent dates by default in the time zone of the view. When the view time zone
is changed, the output of Arcade expressions working with dates may change to match the time zone of the view.
The user can use the ChangeTimeZone Arcade function (e.g.
ChangeTimeZone($feature.dateField, "system")) to display dates in another time zone regardless of web map time zone. Alternatively they can construct Date values in the context of a specific time zone (e.g.Date(2013, 1, 1, 10, 00, 00, 00, "UTC")). - Components/widgets: Date values, including values from 
dateandtimestamp-offsetfields, will be displayed in the view's time zone by default in the following components/widgets: Bookmarks, Editor, Feature, FeatureForm, Features, FeatureTable, Legend, Popup and TimeSlider. 
The time zone can be set to one of the following values:
Possible Values
Value Description system Dates and times will be displayed in the time zone of the device or browser. unknown Dates and times will be displayed based on the time zone that has been defined for the layer. No adjustments are made to the display of date info. TimeSlider is disabled. Specified IANA time zone Dates and times will be displayed in the specified IANA time zone. See wikipedia - List of tz database time zones. If the
timeZoneis set tounknownand a layer’s date/time field includes time information, set the timeStyle property to either long or full on the corresponding date/time field.- Default Value:"system"
 - See also
 
Example// Date and time will be displayed in Pacific/Auckland (NZ) time zone const view = new MapView({ map: map, container: "viewDiv", timeZone: "Pacific/Auckland" }); - Arcade: Arcade expressions referencing date values in labels, renderers, and forms
will represent dates by default in the time zone of the view. When the view time zone
is changed, the output of Arcade expressions working with dates may change to match the time zone of the view.
The user can use the ChangeTimeZone Arcade function (e.g.
 
- 
  
    
Exposes the default widgets available in the view and allows you to toggle them on and off. See DefaultUI for more details.
Exampleslet toggle = new BasemapToggle({ view: view, nextBasemap: "hybrid" }); // Adds an instance of BasemapToggle widget to the // top right of the view. view.ui.add(toggle, "top-right");// Moves the zoom and BasemapToggle widgets to the // bottom left of the view. view.ui.move([ "zoom", toggle ], "bottom-left");// Removes all the widgets from the bottom left of the view view.ui.empty("bottom-left");// Removes the compass widget from the view view.ui.remove("compass");// Removes all default UI components, except Attribution. // Passing an empty array will remove all components. view.ui.components = [ "attribution" ]; 
- 
  
    
Represents the current view as a Viewpoint or point of observation on the view. Setting the viewpoint immediately changes the current view. For animating the view, see goTo().
The returned Viewpoint object is an internal reference which may be modified internally. To persist the returned object, create a copy using Viewpoint.clone().
Notes
- 
If the spatial reference of
viewpointset in the constructor does not match the spatialReference of the view, then projectOperator will be loaded dynamically. - 
At runtime, the projectOperator must be loaded when setting the
viewPointto a spatial reference that doesn't match the view spatial reference. You can check if the projectOperator is loaded prior to setting the center by calling projectOperator.isLoaded(). If it is not yet loaded, you can call projectOperator.load(). 
- See also
 
 - 
 
- 
  
    
The visibleArea represents the visible portion of a map within the view as an instance of a Polygon. This is similar to the view extent but is a more accurate representation of the visible area especially when the view is rotated. An example use of the visible area is to spatially filter visible features in a layer view query.
- See also
 
 
- 
  
  
width
Propertywidth Numberreadonly - 
  
    
The width of the view in pixels read from the view container element.
The view container needs to have a width greater than 0 to be displayed.
- Default Value:0
 
 
- 
  
  
widthBreakpoint
PropertywidthBreakpoint String - 
  
    
A convenience property indicating the general size of the view's width. This value is determined based on where the view's width falls in the ranges defined in the breakpoints property. See the table below for a list of possible values. Use the breakpoints property to override the default thresholds.
Please refer to the styling guide for additional information on working with this.
Possible Value Description Default thresholds (pixels) xsmall The width of the view is smaller than the value set in the xsmallbreakpoint.< 545 small The width of the view is between the values set in the xsmallandsmallbreakpoints.545 - 768 medium The width of the view is between the values set in the smallandmediumbreakpoints.769 - 992 large The width of the view is between the values set in the mediumandlargebreakpoints.993 - 1200 xlarge The width of the view is larger than the value set in the largebreakpoint.> 1200 Possible Values:"xsmall" |"small" |"medium" |"large" |"xlarge"
ExamplereactiveUtils.when( () => view.widthBreakpoint === "xsmall", () => { // clear the view's default UI components if // the app is used on a mobile device view.ui.components = []; } ); 
- 
  
  
zoom
Propertyzoom Number - 
  
    
Represents the level of detail (LOD) at the center of the view. A zoom level or scale is a number that defines how large or small the contents of a map appear in a map view. Zoom level is a number usually between 0 (global view) and 23 (very detailed view) and is used as a shorthand for predetermined scale values. A value of -1 means the view has no LODs. When setting the zoom value, map view converts it to the corresponding scale, or interpolates it if the zoom is a fractional number. MapView can display maps with different projections at a full range of scales, and so use scale rather than zoom level.
Setting the zoom immediately changes the current view. For animating the view, see goTo(). Setting this property in conjunction with center is a convenient way to set the initial extent of the view.
- See also
 
Examplesview.zoom = 3; // Sets the LOD to 3 (small map scale) view.zoom = 18; // Sets the LOD to 18 (large map scale)// Set the zoom level and center in the constructor let view = new MapView({ zoom: 10, center: [-120, 34], map: map }); 
Method Overview
| Name | Return Type | Summary | Class | 
|---|---|---|---|
Adds one or more handles which are to be tied to the lifecycle of the object.  | Accessor | ||
Closes the popup.  | View2D | ||
Destroys the view, and any associated resources, including its map, popup, and UI elements.  | View | ||
Emits an event on the instance.  | View | ||
Promise  | Sets the view to a given target.  | View2D | |
Indicates whether there is an event listener on the instance that matches the provided event name.  | View | ||
Returns true if a named group of handles exist.  | Accessor | ||
  | View | ||
  | View | ||
  | View | ||
Registers an event handler on the instance.  | View | ||
Promise  | Opens the popup at the given location with content defined either explicitly with   | View2D | |
Removes a group of handles owned by the object.  | Accessor | ||
Converts the given screen point to a map point.  | View2D | ||
Converts the given map point to a screen point.  | View2D | ||
Call this method to clear any fatal errors resulting from a lost WebGL context.  | View | ||
Promise  | 
  | View | |
Promise<AnalysisView2DUnion>  | Gets the analysis view created for the given analysis object.  | View2D | |
Promise<LayerView>  | Gets the LayerView created on the view for the given layer.  | View | 
Method Details
- 
  
  
  
  Inherited from Accessor
 - 
  
  
    
Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.
// Manually manage handles const handle = reactiveUtils.when( () => !view.updating, () => { wkidSelect.disabled = false; }, { once: true } ); this.addHandles(handle); // Destroy the object this.destroy();ParametershandleOrHandles WatchHandle|WatchHandle[]Handles marked for removal once the object is destroyed.
groupKey *optionalKey identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.
 
- 
  
  
    
Closes the popup.
Example// Closes the popup if it's open if(view.popup.visible){ view.closePopup(); } 
- 
  
  
  
  Inherited from View
 - 
  
  
    
Destroys the view, and any associated resources, including its map, popup, and UI elements. These can no longer be used once the view has been destroyed. To prevent these components from being destroyed, remove them from the view before calling
destroy().// remove popup and legend from the view so that they are not destroyed const popup = view.popup; view.popup = null; view.ui.remove(legend); // unset map from the view so that it is not destroyed const map = view.map; view.map = null; // destroy the view and any remaining associated resources view.destroy(); 
- 
  
  
    
Sets the view to a given target. The target parameter can be one of the following:
[longitude, latitude]pair of coordinates- Geometry (or array of Geometry[])
 - Graphic (or array of Graphic[])
 - Viewpoint
 - Object with a combination of 
target,center,scaleandrotationproperties (withtargetbeing any of the types listed above). Thecenterproperty is provided as a convenience to animate the MapView.center and is equivalent to specifying thetargetwith the center Point. 
This function returns a promise which resolves as soon as the new view has been set to the target. If the transition is animated, then the ongoing animation can be obtained using MapView.animation. If setting the view to the new target fails, the promise returned by the goTo() method rejects with an error. Use a catch statement, to handle the error:
view.goTo({ center: [-126, 49] }) .catch(function(error) { if (error.name != "AbortError") { console.error(error); } });If a tiled map service is used as the basemap and
snapToZoomproperty is set totruein constraints, thegoTomethod will zoom in to fit the definedtarget. IfsnapToZoomproperty is set tofalse, thegoTomethod will zoom to the exacttarget.Since 4.30: The
goTomethod now respects the user's preference for reduced motion. By default,goTo()will animate, but when the user expresses a preference for reduced motion,goTo()will navigate to the specified target without animation. It is possible to override the user's preference for reduced motion by configuring esriConfig.respectPrefersReducedMotion or on a per-call basis by specifying theanimateproperty. However, if you override the user's preference for reduced motion, you should consider slowing down animations by adjusting thespeedFactorordurationin theoptionsparameter, or provide users with a way to slow down or stop the animation. Refer to implementing reduced motion in your applications for more information.Parameterstarget GoToTarget2DThe target location/viewpoint to animate to. When using an object for
target, use the properties in GoToTarget2D.options GoToOptions2DoptionalAnimation options for controlling the duration and easing of the animation. See the properties defined in GoToOptions2D for object specifications.
ReturnsType Description Promise A promise that resolves when the view's extent updates to the extent defined in target.Exampleslet pt = new Point({ latitude: 49, longitude: -126 }); // go to the given point view.goTo(pt);let opts = { duration: 5000 // Duration of animation will be 5 seconds }; // go to point at LOD 15 with custom duration view.goTo({ target: pt, zoom: 15 }, opts);// go to same point using center and zoom view.goTo({ center: [-126, 49], zoom: 15 }); 
- 
  
  
hasEventListener
InheritedMethodhasEventListener(type){Boolean}Inherited from View - 
  
  
    
Indicates whether there is an event listener on the instance that matches the provided event name.
Parametertype StringThe name of the event.
ReturnsType Description Boolean Returns true if the class supports the input event.  
- 
  
  
hasHandles
InheritedMethodhasHandles(groupKey){Boolean}Inherited from Accessor - 
  
  
    
Returns true if a named group of handles exist.
ParametergroupKey *optionalA group key.
ReturnsType Description Boolean Returns trueif a named group of handles exist.Example// Remove a named group of handles if they exist. if (obj.hasHandles("watch-view-updates")) { obj.removeHandles("watch-view-updates"); } 
- 
  
  
isFulfilled
InheritedMethodisFulfilled(){Boolean}Inherited from View - 
  
  
    
isFulfilled()may be used to verify if creating an instance of the class is fulfilled (either resolved or rejected). If it is fulfilled,truewill be returned.ReturnsType Description Boolean Indicates whether creating an instance of the class has been fulfilled (either resolved or rejected).  
- 
  
  
isRejected
InheritedMethodisRejected(){Boolean}Inherited from View - 
  
  
    
isRejected()may be used to verify if creating an instance of the class is rejected. If it is rejected,truewill be returned.ReturnsType Description Boolean Indicates whether creating an instance of the class has been rejected.  
- 
  
  
isResolved
InheritedMethodisResolved(){Boolean}Inherited from View - 
  
  
    
isResolved()may be used to verify if creating an instance of the class is resolved. If it is resolved,truewill be returned.ReturnsType Description Boolean Indicates whether creating an instance of the class has been resolved.  
- 
  
  
on
InheritedMethodon(type, listener){Object}Inherited from View - 
  
  
    
Registers an event handler on the instance. Call this method to hook an event with a listener.
ParametersReturnsType Description Object 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. Exampleview.on("click", function(event){ // event is the event handle returned after the event fires. console.log(event.mapPoint); }); 
- 
  
  
    
Opens the popup at the given location with content defined either explicitly with
contentor driven from the PopupTemplate of input features. This method sets the popup's visible property totrue. Users can alternatively open the popup by directly setting the visible property totrue.A Popup instance is created and assigned to popup the first time
openPopup()is called, unless popup isnull. The popup then processes the click event.When calling this method, to prevent the popup from opening when clicking on the view, set popupEnabled to
falseto stop event propagation on the view.The popup will only display if the view's size constraints in dockOptions are met or the location property is set to a geometry.
ParametersSpecificationoptions ObjectoptionalDefines the location and content of the popup when opened.
Specificationtitle StringoptionalSets the title of the popup.
content String|HTMLElement|WidgetoptionalSets the content of the popup.
location PointoptionalSets the popup's location, which is the geometry used to position the popup.
fetchFeatures BooleanoptionalDefault Value: falseWhen
true, indicates the popup should fetch the content of this feature and display it. If no PopupTemplate exists, a default template is created for the layer if defaultPopupTemplateEnabled =true. In order for this option to work, there must be a validviewandlocationset.optional Sets the popup's features, which populate the title and content of the popup based on each graphic's PopupTemplate.
promises Promise[]optionalSets pending promises on the popup. The popup will display once the promises resolve. Each promise must resolve to an array of Graphics.
featureMenuOpen BooleanoptionalDefault Value: falseThis property enables multiple features in a popup to display in a list rather than displaying the first selected feature. Setting this to
trueallows the user to scroll through the list of features returned from the query and choose the selection they want to display within the popup.updateLocationEnabled BooleanoptionalDefault Value: falseWhen
true, indicates the popup should update its location for each paginated feature based on the selectedFeature's geometry.collapsed BooleanoptionalDefault Value: falseWhen
true, indicates that only the popup header will display.shouldFocus BooleanoptionalDefault Value: falseWhen
true, indicates that the focus should be on the popup after it has been opened.ReturnsType Description Promise Resolves when the popup is opened. Calling openPopup()orclosePopup()again rejects the Promise.Examples// Opens a popup manually depending on where the user clicks with specified title and content. view.on("click", (event)=>{ view.openPopup({ location: event.mapPoint, title: "You clicked here", content: "This is a point of interest" }); });// Opens popup at the location of the click event and displays // content for the selected features if a popupTemplate is defined. view.on("click", (event)=>{ view.openPopup({ location: event.mapPoint, fetchFeatures: true }); });// Opens popup with the properties specified at the location of the click event // and updates the popup location based on the selected feature's geometry. view.openPopup({ title: "You clicked here", content: "This is a point of interest", location: event.mapPoint, updateLocationEnabled: true });// Opens popup with the specified array of graphics and displays the // features in a list (feature menu) at the location of the first graphic in the array. view.openPopup({ features: graphics, featureMenuOpen: true, location: graphics[0].geometry }); 
- 
  
  
  
  Inherited from Accessor
 - 
  
  
    
Removes a group of handles owned by the object.
ParametergroupKey *optionalA group key or an array or collection of group keys to remove.
Exampleobj.removeHandles(); // removes handles from default group obj.removeHandles("handle-group"); obj.removeHandles("other-handle-group"); 
- 
  
  
toMap
MethodtoMap(screenPoint){Point} - 
  
  
    
Converts the given screen point to a map point. The screen point represents a point in terms of pixels relative to the top-left corner of the view.
ParameterscreenPoint ScreenPoint|MouseEventThe location on the screen (or native mouse event) to convert.
ReturnsType Description Point The map point corresponding to the given screen point.  
- 
  
  
toScreen
MethodtoScreen(point, options){ScreenPoint |null |undefined} - 
  
  
    
Converts the given map point to a screen point. The screen point represents a point in terms of pixels relative to the top-left corner of the view.
Parameterspoint PointA point geometry.
options ToScreenOptions2DoptionalOptions for controlling the toScreen() calculation. See the properties defined in ToScreenOptions2D for object specifications.
ReturnsType Description ScreenPoint | null | undefined The screen point corresponding to the given map point. Example// get the screen point for the specified map point. const mapPoint = { x: -49.97, y: 41.73, spatialReference:{ wkid: 4326 } }; const screenPoint = mapView.toScreen(mapPoint); 
- 
  
  
  
  Inherited from View
 - 
  
  
    
Call this method to clear any fatal errors resulting from a lost WebGL context.
- See also
 
ExamplereactiveUtils.when( () => view.fatalError, () => view.tryFatalErrorRecovery() ); 
- 
  
  
  
  Inherited from View
 - 
  
  
    
when()may be leveraged once an instance of the class is created. This method takes two input parameters: aonFulfilledfunction and anonRejectedfunction. TheonFulfilledexecutes when the instance of the class loads. TheonRejectedexecutes if the instance of the class fails to load.ParametersReturnsType Description Promise Returns a new promise for the result of onFulfilledthat may be used to chain additional functions.Example// Although this example uses MapView, any class instance that is a promise may use when() in the same way let view = new MapView(); view.when(function(){ // This function will execute once the promise is resolved }, function(error){ // This function will execute if the promise is rejected due to an error }); 
- 
  
  
whenAnalysisView
MethodwhenAnalysisView(analysis){Promise<AnalysisView2DUnion>}Since: ArcGIS Maps SDK for JavaScript 4.34View2D since 4.31, whenAnalysisView added at 4.34.  - 
  
  
    
Gets the analysis view created for the given analysis object. The returned promise resolves when the view for the given analysis has been created, or rejects with an error (for example if the analysis does not belong in analyses.
Parameteranalysis AnalysisThe analysis for which to obtain the analysis view.
ReturnsType Description Promise<AnalysisView2DUnion> Resolves to an instance of the analysis view for the provided analysis. Example// Create a slice analysis let analysis = new ElevationProfileAnalysis(); // add to the view view.analyses.add(analysis); view.whenAnalysisView(analysis) .then((analysisView) => { // The analysis view for the analysis }) .catch((error) => { // An error occurred during the analysis view creation }); 
- 
  
  
whenLayerView
InheritedMethodwhenLayerView(layer){Promise<LayerView>}Inherited from View - 
  
  
    
Gets the LayerView created on the view for the given layer. The returned promise resolves when the layer view for the given layer has been created, or rejects with an error (for example if the layer is not part of the view, or if the layer type is not supported in this view).
Parameterlayer LayerThe layer for which to obtain its LayerView.
Returns- See also
 
Example// Create a feature layer from a url pointing to a Feature Service let layer = new FeatureLayer(url); map.add(layer); view.whenLayerView(layer) .then(function(layerView) { // The layerview for the layer }) .catch(function(error) { // An error occurred during the layerview creation }); 
Event Overview
| Name | Type | Summary | Class | 
|---|---|---|---|
| 
     | 
  
  
    {native: Object,defer: EventDefer} | 
       Fires when browser focus is moved away from the view.  | 
  
  
  
    View | 
| 
     | 
  
  
    {mapPoint: Point,x: Number,y: Number,button: Number,buttons: 0|1|2,type: "click",stopPropagation: Function,timestamp: Number,native: Object,defer: EventDefer} | 
       Fires after a user clicks on the view.  | 
  
  
  
    View | 
| 
     | 
  
  
    {mapPoint: Point,x: Number,y: Number,button: Number,buttons: 0|1|2,type: "double-click",stopPropagation: Function,timestamp: Number,native: Object,defer: EventDefer} | 
       Fires after double-clicking on the view.  | 
  
  
  
    View | 
| 
     | 
  
  
    {action: "start"|"added"|"update"|"removed"|"end",x: Number,y: Number,origin: Object,origin.x: Number,origin.y: Number,button: 0|1|2,buttons: Number,type: "drag",radius: Number,angle: Number,stopPropagation: Function,timestamp: Number,native: Object,defer: EventDefer} | 
       Fires during a pointer drag on the view.  | 
  
  
  
    View | 
| 
     | 
  
  
    {native: Object,defer: EventDefer} | 
       Fires when browser focus is on the view.  | 
  
  
  
    View | 
| 
     | 
  
  
    {mapPoint: Point,x: Number,y: Number,button: 0|1|2,buttons: Number,type: "hold",stopPropagation: Function,timestamp: Number,native: Object,defer: EventDefer} | 
       Fires after holding either a mouse button or a single finger on the view for a short amount of time.  | 
  
  
  
    View | 
| 
     | 
  
  
    {mapPoint: Point,x: Number,y: Number,button: 0|1|2,buttons: Number,type: "immediate-click",stopPropagation: Function,timestamp: Number,native: Object,defer: EventDefer} | 
       Fires right after a user clicks on the view.  | 
  
  
  
    View | 
| 
     | 
  
  
    {mapPoint: Point,x: Number,y: Number,button: 0|1|2,buttons: Number,type: "immediate-double-click",stopPropagation: Function,timestamp: Number,native: Object,defer: EventDefer} | 
       Is emitted after two consecutive immediate-click events.  | 
  
  
  
    View | 
| 
     | 
  
  
    {repeat: Boolean,key: String,type: "key-down",stopPropagation: Function,timestamp: Number,native: Object,defer: EventDefer} | 
       Fires after a keyboard key is pressed.  | 
  
  
  
    View | 
| 
     | 
  
  
    {type: "key-up",key: String,stopPropagation: Function,timestamp: Number,native: Object,defer: EventDefer} | 
       Fires after a keyboard key is released.  | 
  
  
  
    View | 
| 
     | 
  
  
    {layer: Layer,layerView: LayerView} | 
       Fires after each layer in the map has a corresponding LayerView created and rendered in the view.  | 
  
  
  
    View | 
| 
     | 
  
  
    {layer: Layer,error: Error} | 
       Fires when an error occurs during the creation of a LayerView after a layer has been added to the map.  | 
  
  
  
    View | 
| 
     | 
  
  
    {layer: Layer,layerView: LayerView} | 
       Fires after a LayerView is destroyed and is no longer rendered in the view.  | 
  
  
  
    View | 
| 
     | 
  
  
    {x: Number,y: Number,deltaY: Number,type: "mouse-wheel",stopPropagation: Function,timestamp: Number,native: Object,defer: EventDefer} | 
       Fires when a wheel button of a pointing device (typically a mouse) is scrolled on the view.  | 
  
  
  
    View | 
| 
     | 
  
  
    {pointerId: Number,pointerType: "mouse"|"touch",x: Number,y: Number,button: Number,buttons: Number,type: "pointer-down",stopPropagation: Function,timestamp: Number,native: Object,defer: EventDefer} | 
       Fires after a mouse button is pressed, or a finger touches the display.  | 
  
  
  
    View | 
| 
     | 
  
  
    {pointerId: Number,pointerType: "mouse"|"touch",x: Number,y: Number,button: Number,buttons: Number,type: "pointer-enter",stopPropagation: Function,timestamp: Number,native: Object,defer: EventDefer} | 
       Fires after a mouse cursor enters the view, or a display touch begins.  | 
  
  
  
    View | 
| 
     | 
  
  
    {pointerId: Number,pointerType: "mouse"|"touch",x: Number,y: Number,button: Number,buttons: Number,type: "pointer-leave",stopPropagation: Function,timestamp: Number,native: Object,defer: EventDefer} | 
       Fires after a mouse cursor leaves the view, or a display touch ends.  | 
  
  
  
    View | 
| 
     | 
  
  
    {pointerId: Number,pointerType: "mouse"|"touch",x: Number,y: Number,button: Number,buttons: Number,type: "pointer-move",stopPropagation: Function,timestamp: Number,native: Object,defer: EventDefer} | 
       Fires after the mouse or a finger on the display moves.  | 
  
  
  
    View | 
| 
     | 
  
  
    {pointerId: Number,pointerType: "mouse"|"touch",x: Number,y: Number,button: Number,buttons: Number,type: "pointer-up",stopPropagation: Function,timestamp: Number,native: Object,defer: EventDefer} | 
       Fires after a mouse button is released, or a display touch ends.  | 
  
  
  
    View | 
| 
     | 
  
  
    {oldWidth: Number,oldHeight: Number,width: Number,height: Number} | 
       Fires when the view's size changes.  | 
  
  
  
    View | 
Event Details
- 
  
  
  
  Inherited from View
 - 
  
  
    
Fires when browser focus is moved away from the view.
- Properties
 - 
  native Object
A standard DOM KeyboardEvent.
defer EventDeferA function that can be called to defer event propagation until the passed in asynchronous function is completed. Calling defer will stall the entire event pipeline and should be used with caution.
 
 
- 
  
  
  
  Inherited from View
 - 
  
  
    
Fires after a user clicks on the view. This event emits slightly slower than an immediate-click event to make sure that a double-click event isn't triggered instead. The immediate-click event can be used for responding to a click event without delay.
- Properties
 - 
  mapPoint Point
The point location of the click on the view in the spatial reference of the map.
x NumberThe horizontal screen coordinate of the click on the view.
y NumberThe vertical screen coordinate of the click on the view.
button NumberIndicates which mouse button was clicked.
buttons NumberIndicates the current mouse button state.
Value Description 0 left click (or touch) 1 middle click 2 right click type StringThe event type.
The value is always "click".
stopPropagation FunctionPrevents the event bubbling up the event chain.
timestamp NumberTime stamp (in milliseconds) at which the event was emitted.
native ObjectA standard DOM PointerEvent.
defer EventDeferA function that can be called to defer event propagation until the passed in asynchronous function is completed. Calling defer will stall the entire event pipeline and should be used with caution.
 - See also
 
Examples// Set up a click event handler and retrieve the screen point view.on("click", function(event) { // the hitTest() checks to see if any graphics in the view // intersect the given screen x, y coordinates view.hitTest(event) .then(getGraphics); });view.on("click", function(event) { // you must overwrite default click-for-popup // behavior to display your own popup view.popupEnabled = false; // Get the coordinates of the click on the view let lat = Math.round(event.mapPoint.latitude * 1000) / 1000; let lon = Math.round(event.mapPoint.longitude * 1000) / 1000; view.popup.open({ // Set the popup's title to the coordinates of the location title: "Reverse geocode: [" + lon + ", " + lat + "]", location: event.mapPoint // Set the location of the popup to the clicked location content: "This is a point of interest" // content displayed in the popup }); }); 
- 
  
  
  
  Inherited from View
 - 
  
  
    
Fires after double-clicking on the view.
- Properties
 - 
  mapPoint Point
The point location of the click on the view in the spatial reference of the map.
x NumberThe horizontal screen coordinate of the click on the view.
y NumberThe vertical screen coordinate of the click on the view.
button NumberIndicates which mouse button was clicked.
buttons NumberIndicates the current mouse button state.
Value Description 0 left click (or touch) 1 middle click 2 right click type StringThe event type.
The value is always "double-click".
stopPropagation FunctionPrevents the event bubbling up the event chain.
timestamp NumberTime stamp (in milliseconds) at which the event was emitted.
native ObjectA standard DOM PointerEvent.
defer EventDeferA function that can be called to defer event propagation until the passed in asynchronous function is completed. Calling defer will stall the entire event pipeline and should be used with caution.
 
Exampleview.on("double-click", function(event) { // The event object contains the mapPoint and the screen coordinates of the location // that was clicked. console.log("screen point", event.x, event.y); console.log("map point", event.mapPoint); }); 
- 
  
  
  
  Inherited from View
 - 
  
  
    
Fires during a pointer drag on the view.
- Properties
 - 
  action String
Indicates the state of the drag. The two values
addedandremovedindicate a change in the number of pointers involved.Possible Values:"start"|"added"|"update"|"removed"|"end"
x NumberThe horizontal screen coordinate of the pointer on the view.
y NumberThe vertical screen coordinate of the pointer on the view.
origin ObjectScreen coordinates of the start of the drag.
button NumberIndicates which mouse button was clicked at the start of the drag. See MouseEvent.button.
Value Description 0 left mouse button (or touch) 1 middle mouse button 2 right mouse button buttons NumberIndicates which mouse buttons are pressed when the event is triggered. See MouseEvent.buttons.
type StringThe event type.
The value is always "drag".
radius NumberThe radius of a sphere around the multiple pointers involved in this drag. Or 0 while only a single pointer is used.
angle NumberAmount of rotation (in degrees) since the last event of type
start.stopPropagation FunctionPrevents the event bubbling up the event chain.
timestamp NumberTime stamp (in milliseconds) at which the event was emitted.
native ObjectA standard DOM MouseEvent.
defer EventDeferA function that can be called to defer event propagation until the passed in asynchronous function is completed. Calling defer will stall the entire event pipeline and should be used with caution.
 
Exampleview.on("drag", function(event){ // Print out the current state of the // drag event. console.log("drag state", event.action); }); 
- 
  
  
  
  Inherited from View
 - 
  
  
    
Fires when browser focus is on the view.
- Properties
 - 
  native Object
A standard DOM KeyboardEvent.
defer EventDeferA function that can be called to defer event propagation until the passed in asynchronous function is completed. Calling defer will stall the entire event pipeline and should be used with caution.
 
 
- 
  
  
  
  Inherited from View
 - 
  
  
    
Fires after holding either a mouse button or a single finger on the view for a short amount of time.
- Properties
 - 
  mapPoint Point
The point location of the click on the view in the spatial reference of the map.
x NumberThe horizontal screen coordinate of the hold on the view.
y NumberThe vertical screen coordinate of the hold on the view.
button NumberIndicates which mouse button was held down. See MouseEvent.button.
Value Description 0 left mouse button (or touch) 1 middle mouse button 2 right mouse button buttons NumberIndicates which mouse buttons are pressed when the event is triggered. See MouseEvent.buttons.
type StringThe event type.
The value is always "hold".
stopPropagation FunctionPrevents the event bubbling up the event chain.
timestamp NumberTime stamp (in milliseconds) at which the event was emitted.
native ObjectA standard DOM PointerEvent.
defer EventDeferA function that can be called to defer event propagation until the passed in asynchronous function is completed. Calling defer will stall the entire event pipeline and should be used with caution.
 
Exampleview.on("hold", function(event) { // The event object contains the mapPoint and the screen coordinates of the location // that was clicked. console.log("hold at screen point", event.x, event.y); console.log("hold at map point", event.mapPoint); }); 
- 
  
  
  
  Inherited from View
 - 
  
  
    
Fires right after a user clicks on the view. In contrast to the click event, the
immediate-clickevent is emitted as soon as the user clicks on the view, and is not inhibited by a double-click event. This event is useful for interactive experiences that require feedback without delay.- Properties
 - 
  mapPoint Point
The point location of the click on the view in the spatial reference of the map.
x NumberThe horizontal screen coordinate of the click on the view.
y NumberThe vertical screen coordinate of the click on the view.
button NumberIndicates which mouse button was clicked. See MouseEvent.button.
Value Description 0 left click (or touch) 1 middle click 2 right click buttons NumberIndicates which buttons are pressed when the event is triggered. See MouseEvent.buttons.
type StringThe event type.
The value is always "immediate-click".
stopPropagation FunctionPrevents the event bubbling up the event chain. Inhibits the associated click and double-click events.
timestamp NumberTime stamp (in milliseconds) at which the event was emitted.
native ObjectA standard DOM PointerEvent.
defer EventDeferA function that can be called to defer event propagation until the passed in asynchronous function is completed. Calling defer will stall the entire event pipeline and should be used with caution.
 
Example// Set up an immediate-click event handler and retrieve the screen point view.on("immediate-click", function(event) { // the hitTest() checks to see if any graphics in the view // intersect the given screen x, y coordinates view.hitTest(event) .then(getGraphics); }); 
- 
  
  
  
  Inherited from View
 - 
  
  
    
Is emitted after two consecutive immediate-click events. In contrast to double-click, an
immediate-double-clickcannot be prevented by use ofstopPropagationon the immediate-click event and can therefore be used to react to double-clicking independently of usage of the immediate-click event.- Properties
 - 
  mapPoint Point
The point location of the click on the view in the spatial reference of the map.
x NumberThe horizontal screen coordinate of the click on the view.
y NumberThe vertical screen coordinate of the click on the view.
button NumberIndicates which mouse button was clicked. See MouseEvent.button.
Value Description 0 left click (or touch) 1 middle click 2 right click buttons NumberIndicates which buttons are pressed when the event is triggered. See MouseEvent.buttons.
type StringThe event type.
The value is always "immediate-double-click".
stopPropagation FunctionPrevents the event bubbling up the event chain.
timestamp NumberTime stamp (in milliseconds) at which the event was emitted.
native ObjectA standard DOM PointerEvent.
defer EventDeferA function that can be called to defer event propagation until the passed in asynchronous function is completed. Calling defer will stall the entire event pipeline and should be used with caution.
 
 
- 
  
  
  
  Inherited from View
 - 
  
  
    
Fires after a keyboard key is pressed.
- Properties
 - 
  repeat Boolean
Indicates whether this is the first event emitted due to the key press, or a repeat.
key StringThe key value that was pressed, according to the MDN full list of key values.
type StringThe event type.
The value is always "key-down".
stopPropagation FunctionPrevents the event bubbling up the event chain.
timestamp NumberTime stamp (in milliseconds) at which the event was emitted.
native ObjectA standard DOM KeyboardEvent.
defer EventDeferA function that can be called to defer event propagation until the passed in asynchronous function is completed. Calling defer will stall the entire event pipeline and should be used with caution.
 
Example// Zoom in when user clicks on "a" button // Zoom out when user clicks on "s" button view.on("key-down", function(event){ console.log("key-down", event); if (event.key === "a"){ let zm = view.zoom + 1; view.goTo({ target: view.center, zoom: zm }); } else if(event.key == "s"){ let zm = view.zoom - 1; view.goTo({ target: view.center, zoom: zm }); } }); 
- 
  
  
  
  Inherited from View
 - 
  
  
    
Fires after a keyboard key is released.
- Properties
 - 
  type String
The event type.
The value is always "key-up".
key StringThe key value that was released, according to the MDN full list of key values.
stopPropagation FunctionPrevents the event bubbling up the event chain.
timestamp NumberTime stamp (in milliseconds) at which the event was emitted.
native ObjectA standard DOM KeyboardEvent.
defer EventDeferA function that can be called to defer event propagation until the passed in asynchronous function is completed. Calling defer will stall the entire event pipeline and should be used with caution.
 
 
- 
  
  
  
  Inherited from View
 - 
  
  
    
Fires after each layer in the map has a corresponding LayerView created and rendered in the view.
- Properties
 - See also
 
Example// This function fires each time a layer view is created for a layer in // the map of the view. view.on("layerview-create", function(event) { // The event contains the layer and its layer view that has just been // created. Here we check for the creation of a layer view for a layer with // a specific id, and log the layer view if (event.layer.id === "satellite") { // The LayerView for the desired layer console.log(event.layerView); } }); 
- 
  
  
  
  Inherited from View
 - 
  
  
    
Fires when an error occurs during the creation of a LayerView after a layer has been added to the map.
- Properties
 - See also
 
Example// This function fires each time an error occurs during the creation of a layerview view.on("layerview-create-error", function(event) { console.error("LayerView failed to create for layer with the id: ", event.layer.id); }); 
- 
  
  
  
  Inherited from View
 - 
  
  
    
Fires when a wheel button of a pointing device (typically a mouse) is scrolled on the view.
- Properties
 - 
  x Number
The horizontal screen coordinate of the click on the view.
y NumberThe vertical screen coordinate of the click on the view.
deltaY NumberNumber representing the vertical scroll amount.
type StringThe event type.
The value is always "mouse-wheel".
stopPropagation FunctionPrevents the event bubbling up the event chain.
timestamp NumberTime stamp (in milliseconds) at which the event was emitted.
native ObjectA standard DOM WheelEvent.
defer EventDeferA function that can be called to defer event propagation until the passed in asynchronous function is completed. Calling defer will stall the entire event pipeline and should be used with caution.
 
Exampleview.on("mouse-wheel", function(event){ // deltaY value is positive when wheel is scrolled up // and it is negative when wheel is scrolled down. console.log(event.deltaY); }); 
- 
  
  
  
  Inherited from View
 - 
  
  
    
Fires after a mouse button is pressed, or a finger touches the display.
- Properties
 - 
  pointerId Number
Uniquely identifies a pointer between multiple down, move, and up events. Ids might get reused after a pointer-up event.
pointerType StringIndicates the pointer type.
Possible Values:"mouse"|"touch"
x NumberThe horizontal screen coordinate of the pointer on the view.
y NumberThe vertical screen coordinate of the pointer on the view.
button NumberIndicates which mouse button was clicked.
buttons NumberIndicates which mouse buttons are pressed when the event is triggered. See MouseEvent.buttons.
type StringThe event type.
The value is always "pointer-down".
stopPropagation FunctionPrevents the event bubbling up the event chain.
timestamp NumberTime stamp (in milliseconds) at which the event was emitted.
native ObjectA standard DOM PointerEvent.
defer EventDeferA function that can be called to defer event propagation until the passed in asynchronous function is completed. Calling defer will stall the entire event pipeline and should be used with caution.
 
 
- 
  
  
  
  Inherited from View
 - 
  
  
    
Fires after a mouse cursor enters the view, or a display touch begins.
- Properties
 - 
  pointerId Number
Uniquely identifies a pointer between multiple events. Ids might get reused after a pointer-up event.
pointerType StringIndicates the pointer type.
Possible Values:"mouse"|"touch"
x NumberThe horizontal screen coordinate of the pointer on the view.
y NumberThe vertical screen coordinate of the pointer on the view.
button NumberIndicates which mouse button was clicked.
buttons NumberIndicates which mouse buttons are pressed when the event is triggered. See MouseEvent.buttons.
type StringThe event type.
The value is always "pointer-enter".
stopPropagation FunctionPrevents the event bubbling up the event chain.
timestamp NumberTime stamp (in milliseconds) at which the event was created.
native ObjectA standard DOM PointerEvent.
defer EventDeferA function that can be called to defer event propagation until the passed in asynchronous function is completed. Calling defer will stall the entire event pipeline and should be used with caution.
 
 
- 
  
  
  
  Inherited from View
 - 
  
  
    
Fires after a mouse cursor leaves the view, or a display touch ends.
- Properties
 - 
  pointerId Number
Uniquely identifies a pointer between multiple events. Ids might get reused after a pointer-up event.
pointerType StringIndicates the pointer type.
Possible Values:"mouse"|"touch"
x NumberThe horizontal screen coordinate of the pointer on the view.
y NumberThe vertical screen coordinate of the pointer on the view.
button NumberIndicates which mouse button was clicked.
buttons NumberIndicates which mouse buttons are pressed when the event is triggered. See MouseEvent.buttons.
type StringThe event type.
The value is always "pointer-leave".
stopPropagation FunctionPrevents the event bubbling up the event chain.
timestamp NumberTime stamp (in milliseconds) at which the event was created.
native ObjectA standard DOM PointerEvent.
defer EventDeferA function that can be called to defer event propagation until the passed in asynchronous function is completed. Calling defer will stall the entire event pipeline and should be used with caution.
 
 
- 
  
  
  
  Inherited from View
 - 
  
  
    
Fires after the mouse or a finger on the display moves.
- Properties
 - 
  pointerId Number
Uniquely identifies a pointer between multiple down, move, and up events. Ids might get reused after a pointer-up event.
pointerType StringIndicates the pointer type.
Possible Values:"mouse"|"touch"
x NumberThe horizontal screen coordinate of the pointer on the view.
y NumberThe vertical screen coordinate of the pointer on the view.
button NumberIndicates which mouse button was clicked.
buttons NumberIndicates which mouse buttons are pressed when the event is triggered. See MouseEvent.buttons.
type StringThe event type.
The value is always "pointer-move".
stopPropagation FunctionPrevents the event bubbling up the event chain.
timestamp NumberTime stamp (in milliseconds) at which the event was created.
native ObjectA standard DOM PointerEvent.
defer EventDeferA function that can be called to defer event propagation until the passed in asynchronous function is completed. Calling defer will stall the entire event pipeline and should be used with caution.
 
Example// Fires `pointer-move` event when user clicks on "Shift" // key and moves the pointer on the view. view.on('pointer-move', ["Shift"], function(event){ let point = view.toMap({x: event.x, y: event.y}); bufferPoint(point); }); 
- 
  
  
  
  Inherited from View
 - 
  
  
    
Fires after a mouse button is released, or a display touch ends.
- Properties
 - 
  pointerId Number
Uniquely identifies a pointer between multiple down, move, and up events. Ids might get reused after a pointer-up event.
pointerType StringIndicates the pointer type.
Possible Values:"mouse"|"touch"
x NumberThe horizontal screen coordinate of the pointer on the view.
y NumberThe vertical screen coordinate of the pointer on the view.
button NumberIndicates which mouse button was clicked.
buttons NumberIndicates which mouse buttons are pressed when the event is triggered. See MouseEvent.buttons.
type StringThe event type.
The value is always "pointer-up".
stopPropagation FunctionPrevents the event bubbling up the event chain. Inhibits the associated immediate-click, click and double-click events.
timestamp NumberTime stamp (in milliseconds) at which the event was created.
native ObjectA standard DOM PointerEvent.
defer EventDeferA function that can be called to defer event propagation until the passed in asynchronous function is completed. Calling defer will stall the entire event pipeline and should be used with caution.
 
 
- 
  
  
  
  Inherited from View
 - 
  
  
    
Fires when the view's size changes.