import SceneView from "@arcgis/core/views/SceneView.js";const SceneView = await $arcgis.import("@arcgis/core/views/SceneView.js");- Since
- ArcGIS Maps SDK for JavaScript 4.0
- Overview
- Using the view
- SceneView navigation
- SceneView navigation with gamepad and 3DConnexion devices
- Programmatic navigation
- Viewing modes
- Supported Coordinate Systems
- Using elevation data
- Handling events
Overview
A SceneView displays a 3D view of a Map or WebScene instance. To render a map and its layers in 2D, see the documentation for MapView. For a general overview of views, see View.

For a map to be visible to the user in the DOM, a SceneView must have both a valid Map instance and a DOM element with a non-zero height and width in which to render. Note that there must be valid data in the map, such as operational layers or a Basemap with base layers, before the view will begin rendering the map.
// Create a basic SceneView instance with a basemap and world elevationconst view = new SceneView({ // An instance of Map or WebScene map: new Map({ basemap: "hybrid" }),
// The id of a DOM element (may also be an actual DOM element) container: "viewDiv"});Known Limitations
The number of features that can be rendered in a SceneView varies depending on the qualityProfile of the view and the complexity of each feature's geometry and symbol. Layers with a large number of features are dynamically loaded and displayed as you navigate the scene. For optimal performance, the number of displayed features is adjusted based on the complexity of the symbol and device capability. As a result, some features may not be visible in the view.
SceneView does not support rendering of Multipoint geometry.
Using the view
A SceneView may not be immediately ready for display after it has been constructed. For example, map data may need to be loaded first to determine the spatialReference of the view, or the DOM container may not yet have a non-zero size. Many of the view methods (such as hitTest() or goTo()) need the view to be ready before they can be used.
Read More
// create a SceneView instance (for 3D viewing)const view = new SceneView({ map: new Map({ basemap: "topo-vector" }), container: "viewDiv"});
view.when(function() { // SceneView is now ready for display and can be used. Here we will // use goTo to view a particular location at a given zoom level, camera // heading and tilt. view.goTo({ center: [-112, 38], zoom: 13, heading: 30, tilt: 60 })}).catch(function(err) { // A rejected view indicates a fatal error making it unable to display, // this usually means that WebGL is not available, or too old. console.error("SceneView rejected:", err);});For live examples of view.when(), see the 2D overview map in SceneView
and Toggle elevation layer samples.
SceneView navigation
The view can be navigated programmatically via goTo() and the view properties or interactively with mouse, keyboard or touch inputs. SceneView navigation is enabled by default, and includes the mouse, keyboard and touch interactions as described in the table below. Touch interactions work on any touch-enabled monitor or laptop screen.
Read More
| Action | SceneView behavior |
|---|---|
| Drag | Pan |
| Double-click | Zoom in at the cursor |
| Scroll Wheel or Middle-click+Drag | Zoom in or out at the cursor |
| Shift + Scroll Wheel or Shift + Middle-click+Drag | Change the camera field of view (focal length) |
| Right-click+Drag | 3D-rotate around the center of the view |
| Arrow Keys | Nudge the view left, right, up, or down (only supported in global scene) |
| B + Left-click+Drag | 3D-rotate around the camera's position |
| P | Move the camera to look perpendicular to the data displayed in the view |
| N | Adjust the SceneView to point north |
| W | Tilt camera up |
| A | Rotate camera counterclockwise |
| S | Tilt camera down |
| D | Rotate camera clockwise |
| J | Move down, closer to the view (only supported in global scene) |
| U | Move up, higher from the view (only supported in global scene) |
| Drag with one finger | Pan |
| Double-tap with one finger | Zoom in at the finger position |
| Two finger pinch in/out | Zoom out/in |
| Move two fingers in clockwise or counterclockwise direction | Rotate |
| Drag two fingers up or down the screen | Tilt the scene |
To disable SceneView navigation, you must call the stopPropagation()
method on the event objects of the pointer or gesture events that trigger the navigation.
See our Disable view navigation sample.
SceneView navigation with Gamepad and 3DConnexion devices
Gamepad and 3Dconnexion devices, like the SpaceMouse, can be used for navigation when view.navigation.gamepad.enabled
is set to true (default). Please see GamepadInputDevice for supported devices.
Read More

| Gamepad Action | SceneView behavior |
|---|---|
| Left Trigger | Descend |
| Right Trigger | Ascend |
| Left Stick | Pan |
| Right Stick | 3D-rotate around the center of the view |
| Action Image | SpaceMouse Action | SceneView behavior |
|---|---|---|
![]() | Push (left/right/forward/backward) | Pan |
![]() | Pull up | Ascend |
![]() | Push down | Descend |
![]() | Rotate clockwise | Rotate the view clockwise |
![]() | Rotate counterclockwise | Rotate the view counterclockwise |
![]() | Tilt | Tilt the scene |
To disable gamepad navigation, you can set view.navigation.gamepad.enabled to false.
Note: Per W3C Working Draft 29 October 2020, gamepad functionality may not be available on some or all browsers if the web application is hosted on a non-secure context (e.g. http rather than https). Future versions of the ArcGIS Maps SDK for JavaScript may explicitly disable gamepad capabilities on non-secure contexts.
Programmatic navigation
Traditional 2D mapping properties, such as scale, zoom, center and extent do not always work well in 3D. For example, a map's scale is not clear when viewed in the context of a globe. The SceneView therefore supports these properties on a best effort basis, with certain limitations (see the documentation of individual properties for more information).
Read More
// Compatibility with 2D viewing properties, such as center and zoom, allows// convenient transitioning from the familiar use of the 2D MapView to the// use of the SceneView for 3D viewing.let view = new SceneView({ map: new Map({ basemap: "satellite" }),
container: "viewDiv",
// Sets the center point of the view at a specified lon/lat center: [-112, 38],
// Sets the zoom LOD to 13 zoom: 13});The nature of 3D viewing includes oblique views, z-values, and rotation, all of which add complexity to defining what is visible in the view. In contrast to 2D MapView, which are primarily defined by an extent, or center and scale, the primary view specification of the SceneView is a Camera instance. The camera is defined by a 3D Camera.position, Camera.heading and Camera.tilt. See the documentation of Camera for more details.
Because some view properties overlap (e.g. center and camera), there is a set priority in which these properties are applied during construction of the view (until the view becomes ready). The following table describes which properties have priority during view construction (properties that are overridden will have no effect during construction).
| Property | Overrides |
|---|---|
| camera | viewpoint, extent, center, scale, zoom |
| viewpoint | extent, center, scale, zoom |
| extent | center, scale, zoom |
| scale | zoom |
It can be difficult to define the camera for viewing data at a particular location. The goTo() method provides a convenient way to set the view's camera based on data (geometries, graphics) you want to view and from any perspective using heading, tilt, scale or zoom. Additionally, goTo() will provide a smooth transition to the new location of the view by default.
// go to a location specified in geographic coordinates,// from a 45 degree angle.view.goTo({ center: [-112, 38], heading: 45});
// go to view all the graphics in view.graphics, while northing the// the camera and tilting it to 60 degreesview.goTo({ target: view.graphics, heading: 0, tilt: 60});
// Set the view to show an extent at a -20 degree heading, disabling the// animated transitionview.goTo({ target: new Extent(694942, 5596444, 1284090, 6163926, SpatialReference.WebMercator), heading: -20}, { animate: false});
Viewing modes

The SceneView supports two different viewing modes, global (left picture above) and local (right picture above),
specified by the viewingMode property. Global scenes render the
earth as a globe, while local scenes render the surface on a flat plane.
Local mode allows for navigation and feature display in a localized or
clipped area. In both viewing modes the users may navigate
the camera below the ground surface by setting the Ground.navigationConstraint.type to none.
The viewing mode (if not explicitly set by the user) is determined
based on the spatial reference of the view. If the spatial reference is either
Web Mercator, WGS84, CGCS2000, Mars_2000_(Sphere), GCS_Mars_2000 or GCS_Moon_2000 then the
viewingMode will default to global. For any other spatial reference the
viewingMode will default to local.
Supported coordinate systems
The SceneView supports following coordinate systems in a global scene:
- SpatialReference.WGS84, SpatialReference.WebMercator and CGCS2000
- Support for Mars_2000_(Sphere), GCS_Mars_2000 and GCS_Moon_2000 is experimental
(see Visualize data on Mars sample). Scenes with these coordinate systems have the following limitations:
- No support for dynamic layers, vector tile layers and scene layers
- Daylight is currently not displayed correctly
- Unable to be saved to a portal item
In a local scene the following coordinate systems are supported:
Noncached layers can be added to scenes with any spatial reference since they will be reprojected to the scene spatial reference.
Cached tiled layers and scene layers can generally only be added to scenes with the same spatial reference. There is limited support for reprojecting cached layers in WebMercator and WGS84 scenes. The following table lists supported spatial references for each viewing mode and spatial reference combination:
| viewing mode | spatial reference | tiled layer spatial reference | scene layer spatial reference |
|---|---|---|---|
| global | WebMercator | WebMercator | WGS84 [1], WebMercator, CGCS2000 |
| global | WGS84 | WGS84 | WGS84 [1], WebMercator, CGCS2000 |
| local | WebMercator | WebMercator | WebMercator [1], WGS84 |
| local | WGS84 | WGS84, WebMercator [2] | WGS84, WebMercator |
| local | Projected CS | same as view | same as view [1] |
| global | CGCS2000 | CGCS2000 | CGCS2000 [1], WGS84, WebMercator |
- [1] the scene layer cache is optimized for this case.
- [2] the tiling scheme of all tiled layers in a scene has to match, so mixing WGS84 and WebMercator tiled layers is not possible.
See spatialReference to learn how the spatial reference of a SceneView is derived.
Using elevation data
The SceneView will use elevation layers from the Map.ground as sources for elevation when rendering the ground surface. Similar to the Map.basemap, the Map.ground can be initialized with a well-known name, which creates it with a known set of elevation layers.
let view = new SceneView({ map: new Map({ basemap: "satellite",
// A ground preset containing a single elevation layer, sourced from // https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer ground: "world-elevation" },
container: "viewDiv"});Local elevation layers can be added to the Ground.layers to merge multiple elevation sources into a single surface. See 3D Map With Elevation Services for an example.
Handling events
When users interact with the SceneView, their actions trigger events that you can listen and respond to. For example, you can listen when a user moves the mouse over the map and display the coordinates at the mouse location. This is called a @pointer-move event. See the SceneView events section for a list of all the events.
Read More
It is important to note that some events are dependent on each other and the timing of the user interaction can influence the type of event that gets triggered. For example, a single click triggers a series of events: @pointer-down when the user presses the mouse button, @pointer-up when they release the mouse button. An @immediate-click event gets triggered right after the @pointer-up event. @immediate-click should be used for responding to user interaction without delay. The @click event is only triggered after making sure that the user doesn't click a second time (in which case it would trigger a @double-click event).

In the case of a double-click, the same event chain is repeated after the first click. However, if the user clicks
a second time within a close time range, then the @click event is not emitted anymore, but the
@pointer-down, @pointer-up and @immediate-click
events are triggered again. After two @immediate-click events, a @double-click
event gets triggered along with an @immediate-double-click event.
The difference between the two is that an @immediate-double-click cannot be prevented
by the use of stopPropagation on the @immediate-click event and can therefore be used to
react to double-clicking independently of usage of the @immediate-click event.
These events are also used internally for navigation, popups or different interactive tools like measurement or
sketch. In some use cases, adding additional event listeners might interfere with the default event listeners.
For example, adding an immediate-click event to open up a popup, will interfere with the default click event
that also opens up a popup.
See the Event explorer sample, to visualize the different events that get triggered when you interact with the view.
Constructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Example
// Typical usagelet view = new SceneView({ // ID of DOM element containing the view container: "viewDiv", // Map/WebScene object map: new Map()});Properties
| Property | Type | Class |
|---|---|---|
views readonly inherited static | ||
allLayerViews readonly inherited | ||
| | ||
| | ||
animation readonly | | |
animationsEnabled inherited | ||
aria inherited | ||
attributionHeight readonly inherited | ||
attributionItems readonly inherited | ReadonlyArray<AttributionItem> | |
attributionMode inherited | ||
attributionVisible inherited | ||
basemapView inherited | ||
breakpoints inherited | ||
| | ||
canZoomIn readonly inherited | ||
canZoomOut readonly inherited | ||
| | ||
| | ||
| | ||
container inherited | ||
declaredClass readonly inherited | ||
displayFilterEnabled inherited | ||
| | ||
| | ||
fatalError inherited | ||
| | ||
focused readonly inherited | ||
graphics inherited | ||
groundView readonly | | |
height readonly inherited | ||
heightBreakpoint inherited | ||
highlights inherited | ||
input readonly inherited | ||
interacting readonly inherited | ||
layerViews readonly inherited | ||
magnifier readonly inherited | ||
map inherited | ||
navigating readonly inherited | ||
navigation inherited | ||
orientation readonly inherited | ||
padding inherited | ||
performanceInfo readonly | | |
popup inherited | ||
popupEnabled inherited | ||
"low" | "medium" | "high" | | |
ready readonly inherited | ||
readyState readonly inherited | "loading" | "missing-map" | "missing-container" | "empty-map" | "map-content-error" | "rendering-error" | "ready" | |
resizing readonly inherited | ||
resolution readonly inherited | ||
| | ||
selectionManager readonly inherited | ||
size readonly inherited | ||
| | ||
stationary readonly inherited | ||
suspended readonly inherited | ||
theme inherited | ||
tileInfo readonly | | |
timeExtent inherited | TimeExtent | null | undefined | |
type readonly | "3d" | |
ui inherited | ||
updating readonly inherited | ||
"global" | "local" | | |
| | ||
visibleArea readonly | | |
width readonly inherited | ||
widthBreakpoint inherited | ||
| |
views
- Type
- Collection<View<any>>
- Since
- ArcGIS Maps SDK for JavaScript 4.11
Contains the collection of active views on the page. Only views that are ready appear in the collection.
allLayerViews
- Type
- ReadonlyCollection
Collection containing a flat list of all the created LayerViews related to the basemap, operational layers, and group layers in this view.
- See also
alphaCompositingEnabled
- Type
- boolean
- Since
- ArcGIS Maps SDK for JavaScript 4.8
Allows the view to be partially or fully transparent when composited with the webpage elements behind it.
This property can only be set once at construction time. When alpha compositing is enabled, web scenes are less
performant. It is important to set this property to true only when you need to apply transparency on the view.
- Default value
- false
Example
// create a view with a fully transparent backgroundlet view = new SceneView({ map: map, alphaCompositingEnabled: true, environment: { background: { type: "color", color: [0, 0, 0, 0] }, starsEnabled: false, atmosphereEnabled: false }}) analyses
- Type
- Collection<Analysis>
A collection of analyses associated with the view.
Examples
// Adds an analysis to the Viewview.analyses.add(lineOfSightAnalysis);// Removes an analysis from the Viewview.analyses.remove(lineOfSightAnalysis); animation
- Type
- ViewAnimation | null | undefined
Represents an ongoing view animation initialized by goTo(). You may watch this property to be notified of animation state changes.
- See also
Example
view.goTo(target, { speedFactor: 0.1 });
reactiveUtils.watch( () => view.animation?.state, (state) => { switch (state) { case "finished": console.log("Animation finished."); break; case "stopped": console.log("Animation stopped."); break; } }); animationsEnabled
- Type
- boolean
- Since
- ArcGIS Maps SDK for JavaScript 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, MapView.goTo()). Setting this property to false disables
all animations in the view.
- Default value
- true
aria
- Type
- DOMContainerAria
- Since
- ArcGIS Maps SDK for JavaScript 4.34
The ARIA attributes for the view container.
attributionHeight
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The height of the attribution in pixels. The value is practical to adjust the bottom padding of other UI elements. The value changes when the attribution is expanded or collapsed.
attributionItems
- Type
- ReadonlyArray<AttributionItem>
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The array of attribution items to be displayed in the view's attribution. This property is populated once the view has finished updating. Items are ordered based on descending score with higher scored items appearing first in the attribution.

Example
// Access the attributionItems property after the view is finished updating to get the array of attribution items to be displayed in the view's attributionreactiveUtils.when( () => !view.updating, () => { const attributionText = view.attributionItems .map((item) => item.text) .join(" | "); console.log(attributionText); }); attributionMode
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The light or dark mode used to display the attribution. By default, the mode is inherited from the Calcite's mode. You can override the value to style the attribution alongside the map or scene content.
attributionVisible
- Type
- boolean
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Indicates whether the attribution is visible in the view.
Esri requires that when you use an ArcGIS Online basemap in your app, the map must include Esri attribution and you must be licensed to use the content. For detailed guidelines on working with attribution, please visit the official attribution in your app documentation. For information, see the Terms of Use documentation.
- Default value
- true
basemapView
- Type
- BasemapView
Represents the view for a single basemap after it has been added to the map.
breakpoints
- Type
- Breakpoints
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 @media calls.
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.
Example
// Instead of watching the size or resizing propertiesreactiveUtils.watch(() => view.size, () => {});reactiveUtils.watch(() => view.resizing, () => {});
// Set up a watch handle for breakpointreactiveUtils.watch( () => view.widthBreakpoint, (breakpoint) => { switch (breakpoint) { case "xsmall": // do something break; case "small": case "medium": case "large": case "xlarge": // do something else break; default: } }); camera
- Type
- Camera
The observation point from which the visible portion (or perspective) of the SceneView is determined. Contains properties including the elevation, tilt, and heading (in degrees) of the current view. Setting the camera immediately changes the current view. For animating the view, see goTo().
When set in the constructor, this property overrides the viewpoint, extent, center, scale, and zoom properties.
The camera property contains an internal reference which may be modified in the future. To persist or modify the camera, create a clone using Camera.clone().
Z-values defined in a geographic or metric coordinate system are expressed in meters. However, in local scenes that use a projected coordinate system, vertical units are assumed to be the same as the horizontal units specified by the service.
- See also
Examples
// Initializes the view at the given (x, y, z) position with a heading of 95 degrees.// The position of the camera is a Point which will autocast in the sample// below. Note that the default Point spatial reference is WGS84 which// will only work if the SceneView has a Web Mercator or WGS84 spatial// reference. For other spatial references, create a new position Point// with an explicit spatial reference.const view = new SceneView({ camera: { position: [ -122, // lon 38, // lat 50000 // elevation in meters ],
heading: 95 }});// Initializes the view at the given position with a tilt of 65 degreesconst view = new SceneView({ camera: { position: { x: -100, // lon y: 45, // lat z: 10654 // elevation in meters },
tilt: 65 }});// Clone the camera to modify its propertiesconst camera = view.camera.clone();
// Set new values for heading and tiltcamera.heading = 180;camera.tilt = 45;
// Set the new properties on the view's cameraview.camera = camera;// Set the view's camera to a new position, heading and tilt with the goTo() methodview.goTo({ target: [-122, 38, 50000], heading: 180, tilt: 45}); center
- Type
- Point
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().
If set in the constructor, this property will be ignored if the viewpoint, camera, or extent properties are also set in the constructor.
The center property contains an internal reference which may be modified in the future. To persist or modify the center, create a clone using center.clone().
Z-values defined in a geographic or metric coordinate system are expressed in meters. However, in local scenes that use a projected coordinate system, vertical units are assumed to be the same as the horizontal units specified by the service.
- See also
Examples
// Sets the initial center point of the view to long/lat coordinateslet view = new SceneView({ center: [-112, 38]});// Updates the view's center point to a pre-determined Point objectview.center = new Point({ x: 12804.24, y: -1894032.09, z: 12000,
spatialReference: 2027});// view.center needs to be set (not modified in place) to have an effect.// To modify only the center.x, first clone the current center, modify// the .x property and then set it on the view.let center = view.center.clone();
// Offset the center 1km to the eastcenter.x += 1000;
view.center = center; clippingArea
Represents an optional clipping area used to define the visible Extent of a local scene. The clipping area cannot have z-values.
If defined, only features that intersect the area will be displayed. The clipping area applies to all layer types, including the ground and the basemap. The clipping area will not increase the area beyond the union of the extents of all layers, including the ground and the basemap. To do so, add a GraphicsLayer with a custom fullExtent to the scene.
The clippingArea property only applies to local scenes.

The clippingArea property contains an internal reference which may be modified in the future. To persist or modify the clippingArea, create a clone using clippingArea.clone().
Example
let extent = view.extent.clone();
// Expand the extent in place, reducing it to 50% of its original size and set it as the clippingAreaview.clippingArea = extent.expand(0.5); constraints
- Type
- Constraints
Specifies constraints for Camera tilt and altitude that may be applied to the SceneView. See the object specification table below for details.
container
- Type
- HTMLDivElement | null | undefined
The id or node representing the DOM element containing the view. This is typically set in the view's constructor.
Examples
// Sets container to the DOM idlet view = new MapView({ container: "viewDiv" // ID of the HTML element that holds the view});// Sets container to the nodelet viewNode = document.getElementById("viewDiv");let view = new SceneView({ container: viewNode}); displayFilterEnabled
- Type
- boolean
- Since
- ArcGIS Maps SDK for JavaScript 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 to false.
- Default value
- true
environment
- Type
- Environment
Specifies various properties of the environment's visualization in the view. The SceneView will redraw automatically when any property of the environment changes.
Modifying the lighting:
let view = new SceneView({ map: map, container: "viewDiv"});
// Set the light source position to reflect the current sun position at that timeview.environment.lighting = { type: "sun", date: new Date("January 1, 2022 12:00:00 UTC")};
// Change the lighting to virtual, so that everything in the scene is nicely lit:view.environment.lighting = { type: "virtual"};
// Enable displaying shadows cast by the light sourceview.environment.lighting.directShadowsEnabled = true;Setting the background:
// Set a background colorlet view = new SceneView({ container: "viewDiv", map: map, environment: { background: { type: "color", color: [255, 252, 244, 1] }, starsEnabled: false, atmosphereEnabled: false }});Changing the weather in the scene:
let view = new SceneView({ container: "viewDiv",
map: new Map({ basemap: "satellite", ground: "world-elevation" }), environment: { weather: { type: "cloudy" // autocasts as new CloudyWeather() } }}); extent
- Type
- Extent
The extent represents the visible portion of a Map within the view as an instance of an Extent. Setting the extent immediately changes the view without animation. To animate the view, see goTo().
Rather than using extent to change the visible portion of the Map in a SceneView, you should use camera since it easily allows you to define the heading, elevation and tilt of the observation point from which the view's perspective is created.
When set in the constructor, this property overrides the center, scale, and zoom properties. This property will be ignored if the viewpoint or camera are also set in the constructor.
The extent property contains an internal reference which may be modified in the future. To persist or modify the extent, create a clone using Extent.clone().
Z-values defined in a geographic or metric coordinate system are expressed in meters. However, in local scenes that use a projected coordinate system, vertical units are assumed to be the same as the horizontal units specified by the service.
fatalError
- Since
- ArcGIS Maps SDK for JavaScript 4.12
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
Example
reactiveUtils.when( () => view.fatalError, () => { console.error("Fatal Error! View has lost its WebGL context. Attempting to recover..."); view.tryFatalErrorRecovery(); }); floors
- Type
- Collection<string>
- Since
- ArcGIS Maps SDK for JavaScript 4.19
Applies a display filter on the view for a specific set of floor levels. It filters the scene display on floor-aware layers by zero or more level IDs.
focused
- Type
- boolean
- Since
- ArcGIS Maps SDK for JavaScript 4.7
Indicates if the browser focus is on the view.
graphics
- Type
- Collection<Graphic>
Allows for adding graphics directly to the default graphics in the View.
Examples
// Adds a graphic to the Viewview.graphics.add(pointGraphic);// Removes a graphic from the Viewview.graphics.remove(pointGraphic); groundView
- Type
- GroundView
- Since
- ArcGIS Maps SDK for JavaScript 4.7
The view for the ground of the map.
height
- Type
- number
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
- Type
- BreakpointSize
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 xsmall breakpoint. | < 545 |
| small | The height of the view is between the values set in the xsmall and small breakpoints. | 545 - 768 |
| medium | The height of the view is between the values set in the small and medium breakpoints. | 769 - 992 |
| large | The height of the view is between the values set in the medium and large breakpoints. | 993 - 1200 |
| xlarge | The height of the view is larger than the value set in the large breakpoint. | > 1200 |
Example
reactiveUtils.watch( () => view.heightBreakpoint === "xsmall", () => { // clear the view's default UI components if // the app is used on a mobile device view.ui.components = []; }); highlights
- Type
- Collection<HighlightOptions>
- Since
- ArcGIS Maps SDK for JavaScript 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's options parameter. If
no name is provided, the feature will use the default highlight 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 onelet 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 positionview.highlights.add(selectionGroup, 0); layerViews
- Type
- Collection
A collection containing a hierarchical list of all the created LayerViews of the operational layers in the map.
- See also
map
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
- Type
- Navigation
- Since
- ArcGIS Maps SDK for JavaScript 4.9
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
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 Value | Description |
|---|---|
| landscape | The width of the view is greater than its height. |
| portrait | The width of the view is equal to or smaller than its height. |
padding
- Type
- ViewPadding
Use the padding property to make the center, and extent, etc. work off a subsection of the full view. This is particularly useful when layering UI elements or semi-transparent content on top of portions of the view.
- Default value
- {left: 0, top: 0, right: 0, bottom: 0}
performanceInfo
- Since
- ArcGIS Maps SDK for JavaScript 4.15
This property contains performance information in a SceneView like global memory usage and additional details for layers about memory consumption and number of features.
This property is experimental and should be used for debugging purposes only. Its interface will change in future releases.
popup
A Popup object that displays general content or attributes from layers in the map.
By default, the popup property 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 is true, when the openPopup method is called,
or when some widgets need the popup, such as Search. If popup is null, the popup instance will not be created.
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
- Type
- boolean
- Since
- ArcGIS Maps SDK for JavaScript 4.27
Controls whether the popup opens when users click on the view.
When true, a Popup instance is created
and assigned to popup the first time the user clicks on the view,
unless popup is null. 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.
- See also
- Default value
- true
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 ... });}); qualityProfile
- Type
- "low" | "medium" | "high"
SceneView can draw scenes in three different quality modes: high, medium and low.
qualityProfile is evaluated and set automatically when SceneView loads depending on the detected device,
to optimize stability and performance across different hardware and browsers.
In most scenarios it is recommended to not set qualityProfile, but let it be evaluated automatically.
qualityProfile should only be set when the target devices and their capabilities that the application runs on
are clear, and are known to work well with the chosen profile.
Applications should also consider providing an option to change the quality profile, such that users can select
the profile that works best with their specific devices.
The quality profiles have increasingly higher settings for the memory limit and rendering quality.
The memory limit defines the maximum amount of memory which the view is allowed to use. Complex web scenes with many layers will hit the memory limit. When this happens, the view will reduce the level of detail and the number of features that are loaded, as well as the rendering resolution of the view and of draped content. This will make the application less likely crash due to out of memory errors.
The rendering quality settings impacts the level of detail and the maximum number of features that are loaded by all layers. A higher quality profile also enables more rendering features, providing better visuals. Furthermor, it increases the resolution of shadows, rasterized content such as icons and text, as well as the overall rendering resolution on HiDPI displays.
A higher quality profile improves visual quality and detail, but can have a negative impact on drawing performance and stability.
SceneView performance depends on the amount of data being displayed, the quality profile and the device type. performanceInfo can be used to inspect the memory consumption and the number of features that are displayed for a specific scene. The SceneView memory resources sample shows how this property can be used.
The default value is based on the detected browser:
lowfor all browsers on iPhonesmediumfor any other browser and device
Example
let view = new SceneView({ qualityProfile: "high"}); ready
- Type
- boolean
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 ascale. These also can be inferred by setting anextent.
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.ready and providing
logic for cases where the map or container change.
- See also
- Default value
- false
readyState
- Type
- "loading" | "missing-map" | "missing-container" | "empty-map" | "map-content-error" | "rendering-error" | "ready"
- Since
- ArcGIS Maps SDK for JavaScript 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 |
|---|---|
loading | The view is currently loading information from the map. |
ready | The view is ready. This is similar to the ready property. |
missing-map | The view is missing a map. Set the view's map property. |
missing-container | The view is missing a container. Set the view's container property. |
empty-map | The view's map has no layers. Add layers to the map. |
rendering-error | The view failed to render. This is similar to the fatalError property. |
map-content-error | The view failed to find information from the map and couldn't derive the spatialReference. Verify that the map correctly loaded with the loadError property, as well as its basemap, and the first layer in the map's layers collection. Alternatively, set a valid center, scale, and spatialReference. |
- 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); }}); resizing
- Type
- boolean
Indicates whether the view is being resized.
- Default value
- false
resolution
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 4.9
Represents the current value of one pixel in the unit of the view's spatialReference. The value of resolution is calculated by dividing the view's extent width by its width.
scale
- Type
- number
Represents an approximation of the map scale. Setting the scale immediately changes the current view. For animating the view, see goTo().
When set in the constructor, this property overrides the zoom property. This property will be ignored if the viewpoint, camera, or extent properties are also set in the constructor.
- See also
Example
// Set the approximate map scale to 1:24,000view.scale = 24000; selectionManager
- Type
- SelectionManager
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The default SelectionManager for this view. Used to manage selections of features across layers.
size
An array containing the width and height of the view in pixels, e.g. [width, height].
spatialReference
- Type
- SpatialReference
The spatial reference of the view.
This indicates the projected or geographic coordinate system used to locate geographic features in the map. In a SceneView the following coordinate systems are available.
The spatial reference can either be set explicitly or automatically derived from the following:
- If the map is a WebScene instance, the WebScene.initialViewProperties.spatialReference is used.
- Otherwise, the spatial reference is derived from the first layer that loads in this order:
In case the spatial reference is determined from the map layers or the ground layers and they are in WGS84 or Web Mercator, the following rule also applies: the first layer that does not support server side reprojection (tiled layers) determines the spatial reference of the view and all the other layers are reprojected.
If no spatial reference can be derived, then the view does not resolve and the ready property is false.
suspended
- Type
- boolean
Indicates if the view is visible on the page. When true, the view is not visible and it stops rendering and updating data.
Set to true when 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 visibility is set to hidden, this property is set to false, and
the view is hidden but it stills renders and updates data.
- Default value
- true
theme
- Since
- ArcGIS Maps SDK for JavaScript 4.28
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.
Example
// Update the theme to use purple graphics// and slightly transparent green textview.theme = new Theme({ accentColor: "purple", textColor: [125, 255, 13, 0.9]}); timeExtent
- Type
- TimeExtent | null | undefined
- Since
- ArcGIS Maps SDK for JavaScript 4.12
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.
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") }}); ui
- Type
- DefaultUI
Exposes the default widgets available in the view and allows you to toggle them on and off. See DefaultUI for more details.
Examples
let 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 viewview.ui.empty("bottom-left");// Removes the compass widget from the viewview.ui.remove("compass");// Removes all default UI components, except Attribution.// Passing an empty array will remove all components.view.ui.components = [ "attribution" ]; viewingMode
- Type
- "global" | "local"
The viewing mode (local or global). Global scenes render the earth as a sphere.
Local scenes render the earth on a flat plane and allow for navigation and feature
display in a localized or clipped area. Users may also navigate
the camera of a local scene below the surface of a basemap.
| Value | Example | Description |
|---|---|---|
| global | ![]() | Global scenes allow the entire globe to render in the view, showing the curvature of the earth. |
| local | ![]() | Local scenes render the earth on a flat surface. They can be constrained to only show a "local" area by setting the clippingArea property. Local scenes also allow for displaying and exploring data that would otherwise be hidden by the surface of the earth. |
Depending on the viewing mode different supported coordinate systems are available.
- Default value
- "global"
viewpoint
- Type
- Viewpoint
Represents the current view as a Viewpoint or point of observation on the view. In SceneViews, camera should be used in favor of viewpoint for watching or changing the point of view. Setting the viewpoint immediately changes the current view. For animating the view, see goTo().
When set in the constructor, this property overrides the extent, center, scale, and zoom properties. This property will be ignored if camera is also set in the constructor.
The viewpoint property contains an internal reference which may be modified in the future. To persist or modify the viewpoint, create a clone using Viewpoint.clone().
- See also
visibleArea
- Since
- ArcGIS Maps SDK for JavaScript 4.31
The visibleArea represents the visible portion of a Map within the view as an instance of a Polygon. The polygon is a 2D approximation of the 3D frustum projected onto the ground surface. This can give more precise results than the view extent, although it is still only an approximation of the 3D visible volume. An example use of the visible area is to spatially filter visible features in a layer view query.
This property does not consider occlusions caused by terrain features (e.g. hills, mountains) or 3D structures (e.g. buildings). Consequently, the visible area may include areas that are actually hidden from the user's view.
The visible area may contain multiple rings, for example the view intersects with the international date line or the poles.
width
- Type
- number
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
- Type
- BreakpointSize
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 xsmall breakpoint. | < 545 |
| small | The width of the view is between the values set in the xsmall and small breakpoints. | 545 - 768 |
| medium | The width of the view is between the values set in the small and medium breakpoints. | 769 - 992 |
| large | The width of the view is between the values set in the medium and large breakpoints. | 993 - 1200 |
| xlarge | The width of the view is larger than the value set in the large breakpoint. | > 1200 |
Example
reactiveUtils.when( () => view.widthBreakpoint === "xsmall", () => { // clear the view's default UI components if // the app is used on a mobile device view.ui.components = []; }); zoom
- Type
- number
Represents the level of detail (LOD) at the center of the view. 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.
If set in the constructor, this property will be ignored if the viewpoint, camera, extent, or scale properties are also set in the constructor.
- See also
Examples
view.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 constructorlet view = new SceneView({ zoom: 10, center: [-120, 34], map: map});Methods
| Method | Signature | Class |
|---|---|---|
closePopup inherited | closePopup(): void | |
destroy inherited | destroy(): void | |
emit inherited | emit<Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean | |
focus inherited | focus(): void | |
goTo(target: GoToTarget3D, options?: GoToOptions3D): Promise<void> | | |
hasEventListener inherited | hasEventListener<Type extends EventNames<this>>(type: Type): boolean | |
hitTest(screenPoint: ScreenPoint | MouseEvent, options?: HitTestOptions3D): Promise<SceneViewHitTestResult> | | |
isFulfilled inherited | isFulfilled(): boolean | |
isRejected inherited | isRejected(): boolean | |
isResolved inherited | isResolved(): boolean | |
on<Type extends EventNames<this>>(type: Type, listener: (event: this["@eventTypes"][Type]) => void): ResourceHandle | | |
on<Type extends EventNames<this>>(type: Type, modifiers: string[], listener: (event: this["@eventTypes"][Type]) => void): ResourceHandle | | |
openPopup inherited | openPopup(options?: ViewPopupOpenOptions): Promise<void> | |
takeScreenshot(options?: Partial<ScreenshotUserSettings>): Promise<Screenshot> | | |
toMap(screenPoint: ScreenPoint | MouseEvent, options?: HitTestOptions3D): Point | null | undefined | | |
toScreen(point: Point): ScreenPoint | | |
tryFatalErrorRecovery inherited | tryFatalErrorRecovery(): void | |
when inherited | when<TResult1 = this, TResult2 = never>(onFulfilled?: OnFulfilledCallback<this, TResult1> | null | undefined, onRejected?: OnRejectedCallback<TResult2> | null | undefined): Promise<TResult1 | TResult2> | |
whenAnalysisView<AnalysisType extends Analysis>(analysis: AnalysisType): Promise<AnalysisView3DFor<AnalysisType>> | | |
whenLayerView<TLayer extends Layer>(layer: TLayer): Promise<Layer extends TLayer ? LayerView : LayerView3DFor<TLayer>> | | |
zoomIn(): Promise<void> | | |
zoomOut(): Promise<void> | |
destroy
- Signature
-
destroy (): void
- Since
- ArcGIS Maps SDK for JavaScript 4.17
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 destroyedconst popup = view.popup;view.popup = null;view.ui.remove(legend);
// unset map from the view so that it is not destroyedconst map = view.map;view.map = null;
// destroy the view and any remaining associated resourcesview.destroy();- Returns
- void
emit
- Signature
-
emit <Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean
- Type parameters
- <Type extends EventNames<this>>
- Since
- ArcGIS Maps SDK for JavaScript 4.5
Emits an event on the instance. This method should only be used when creating subclasses of this class.
focus
- Signature
-
focus (): void
- Since
- ArcGIS Maps SDK for JavaScript 4.5
Sets the focus on the view.
- Returns
- void
goTo
- Signature
-
goTo (target: GoToTarget3D, options?: GoToOptions3D): Promise<void>
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
- Camera
- Object with a combination of
target,center,scale,position,headingandtiltproperties (withtargetbeing any of the types listed above). Thecenterproperty is provided as a convenience to animate the center and is the equivalent of specifying thetargetwith the center Point. The target must be provided in the spatial reference of the view.
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 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 the given target is far away from the current camera position, then heading and tilt will be automatically set to their neutral values (facing north, looking top down). Tilt and heading can always be explicitly set to override this behavior.
- See also
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| target | The target location/viewpoint to go to.
When using an object for | | |
| options | View transition options. See the specification defined in GoToOptions3D for more information. | |
Examples
view.goTo({ center: [-126, 49], heading: 180, // set the heading to point South tilt: view.camera.tilt, // maintain tilt value});// go to a location defined by a Camera objectlet cam = new Camera({ position: new Point({ x: -100.23, // lon y: 65, // lat z: 10000, // elevation in meters }),
heading: 180, // facing due south tilt: 45 // bird's eye view});
view.goTo(cam);// go to a point using center, zoom, tilt, and headingview.goTo({ center: [-126, 49], zoom: 13, tilt: 75, heading: 105});// goTo returns a Promise which resolves when the animation has finished.// This promise may be chained to create a sequence of animations.view.goTo(graphic1) .then(function() { return view.goTo(graphic2); }) .then(function() { return view.goTo(graphic3); }); hasEventListener
- Signature
-
hasEventListener <Type extends EventNames<this>>(type: Type): boolean
- Type parameters
- <Type extends EventNames<this>>
Indicates whether there is an event listener on the instance that matches the provided event name.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| type | Type | The name of the event. | |
- Returns
- boolean
Returns true if the class supports the input event.
hitTest
- Signature
-
hitTest (screenPoint: ScreenPoint | MouseEvent, options?: HitTestOptions3D): Promise<SceneViewHitTestResult>
Returns hit test results from each layer that intersects the specified screen coordinates. The results are organized as an array of objects containing different result types.
The following layer types will return all features if a hit is made on intersecting features: GraphicsLayer, FeatureLayer, SceneLayer, BuildingSceneLayer, PointCloudLayer, CSVLayer, StreamLayer, GeoJSONLayer, OGCFeatureLayer, and graphics.
The MediaLayer hit test result contains all media elements if the hit is made on intersecting elements. The RouteLayer hit test result contains all route elements if the hit is made on intersecting elements.
The VoxelLayer hit test result contains information about the intersecting voxel if a hit is made.
If no options are specified, graphics that are behind the ground surface will not be returned unless the ground surface is semi-transparent. Otherwise, using the Map.ground in the include and exclude options determines whether the ground surface prevents hit testing graphics that are under it.
Release-specific changes:
- At version 4.24, SceneViewHitTestResult returns an array of objects containing graphic, media element, and route.
- Starting with version 4.11, if a label intersects the specified screen coordinates then the result of the hitTest will contain the graphic associated with that label.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| screenPoint | The screen coordinates (or native mouse event) of the click on the view. | | |
| options | Intersection test options. By default the Map.ground is excluded if its opacity is smaller than one. | |
- Returns
- Promise<SceneViewHitTestResult>
When resolved, returns an array of objects containing different result types.
Example
// Get the screen point from the view's click eventview.on("click", function(event) { // Search for graphics at the clicked location. View events can be used // as screen locations as they expose an x,y coordinate that conforms // to the ScreenPoint definition. view.hitTest(event).then(function(response) { let result = response.results[0];
if (result?.type === "graphic") { let lon = result.mapPoint.longitude; let lat = result.mapPoint.latitude;
console.log("Hit graphic at (" + lon + ", " + lat + ")", result.graphic); } else { console.log("Did not hit any graphic"); } });}); isFulfilled
- Signature
-
isFulfilled (): boolean
isFulfilled() may be used to verify if creating an instance of the class is fulfilled (either resolved or rejected).
If it is fulfilled, true will be returned.
- Returns
- boolean
Indicates whether creating an instance of the class has been fulfilled (either resolved or rejected).
isRejected
- Signature
-
isRejected (): boolean
isRejected() may be used to verify if creating an instance of the class is rejected.
If it is rejected, true will be returned.
- Returns
- boolean
Indicates whether creating an instance of the class has been rejected.
isResolved
- Signature
-
isResolved (): boolean
isResolved() may be used to verify if creating an instance of the class is resolved.
If it is resolved, true will be returned.
- Returns
- boolean
Indicates whether creating an instance of the class has been resolved.
on
- Signature
-
on <Type extends EventNames<this>>(type: Type, listener: (event: this["@eventTypes"][Type]) => void): ResourceHandle
- Type parameters
- <Type extends EventNames<this>>
Registers an event handler on the instance. Call this method to hook an event with a listener. See the Events summary table for a list of listened events.
Parameters
- Returns
- ResourceHandle
Returns an event handler with a
remove()method that can be called to stop listening for the event.Property Type Description remove Function When called, removes the listener from the event.
Examples
view.on("click", function(event){ // event is the event handle returned after the event fires. console.log(event.mapPoint);});
// 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);});view.on("click", function(event){ // event is the event handle returned after the event fires. console.log(event.mapPoint);}); on
- Signature
-
on <Type extends EventNames<this>>(type: Type, modifiers: string[], listener: (event: this["@eventTypes"][Type]) => void): ResourceHandle
- Type parameters
- <Type extends EventNames<this>>
Registers an event handler on the instance. Call this method to hook an event with a listener.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| type | Type | The name of the event or events to listen for. | |
| modifiers | string[] | Additional modifier keys to filter events. Please see Key Values for possible values. All the standard key values are supported. Alternatively, if no modifiers are required, the function will call when the event fires. The following events don't support modifier keys: | |
| listener | The function to call when the event is fired, if modifiers were specified. | |
- Returns
- ResourceHandle
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.
Example
view.on("click", function(event){ // event is the event handle returned after the event fires. console.log(event.mapPoint);}); openPopup
- Signature
-
openPopup (options?: ViewPopupOpenOptions): Promise<void>
- Since
- ArcGIS Maps SDK for JavaScript 4.27
Opens the popup at the given location with content defined either explicitly with content
or driven from the PopupTemplate of input features. This method sets
the popup's visible property to true. Users can alternatively open the popup
by directly setting the visible property to true.
A Popup instance is created
and assigned to popup the first time openPopup() is called,
unless popup is null.
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 false to 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.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| options | Defines the location and content of the popup when opened. | |
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}); takeScreenshot
- Signature
-
takeScreenshot (options?: Partial<ScreenshotUserSettings>): Promise<Screenshot>
- Since
- ArcGIS Maps SDK for JavaScript 4.9
Create a screenshot of the current view. Screenshots include only elements that are rendered on the canvas (all geographical elements), but excludes overlaid DOM elements (UI, popups, etc.). By default, a screenshot of the whole view is created. Different options allow for creating different types of screenshots, including taking screenshots at different aspect ratios, different resolutions and creating thumbnails.
Screenshots are always taken inside the padded area of the view (see padding).
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| options | Screenshot options. | |
- Returns
- Promise<Screenshot>
When resolved, returns an object containing an encoded dataUrl and raw image data.
Examples
// Take a screenshot at the same resolution of the current viewview.takeScreenshot().then(function(screenshot) { let imageElement = document.getElementById("screenshotImage"); imageElement.src = screenshot.dataUrl;});// Create a square thumbnail from the current viewlet options = { width: 200, height: 200};
view.takeScreenshot(options).then(function(screenshot) { let imageElement = document.getElementById("screenshotImage"); imageElement.src = screenshot.dataUrl;});// Take a high resolution, square screenshotlet options = { width: 2048, height: 2048};
view.takeScreenshot(options).then(function(screenshot) { let imageElement = document.getElementById("screenshotImage"); imageElement.src = screenshot.dataUrl;});// Take a screenshot of a small area at the center of the view
// Compute the size of the view excluding potential paddinglet padding = view.padding;let innerWidth = view.width - padding.left - padding.right;let innerHeight = view.height - padding.top - padding.bottom;
// Desired size of the arealet width = 200;let height = 200;
let options = { area: { x: (innerWidth - width) / 2, y: (innerHeight - height) / 2, width: width, height: height }};
view.takeScreenshot(options).then(function(screenshot) { let imageElement = document.getElementById("screenshotImage"); imageElement.src = screenshot.dataUrl;});// Takes a high-resolution screenshot for display on a HiDPI screen// The pixelRatio indicates the display has 2x the pixel density of typical screenslet pixelRatio = 2;view.takeScreenshot({ width: view.width * pixelRatio, height: view.height * pixelRatio });// Takes a high-resolution screenshot for display on a HiDPI screen// The pixelRatio is the resolution of the display capturing the imagelet pixelRatio = window.devicePixelRatio;view.takeScreenshot({ width: view.width * pixelRatio, height: view.height * pixelRatio }); toMap
- Signature
-
toMap (screenPoint: ScreenPoint | MouseEvent, options?: HitTestOptions3D): Point | null | undefined
Converts the given screen point to a map point.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| screenPoint | The location on the screen (or native mouse event) to convert. | | |
| options | Intersection test options. By default only the Map.ground and any IntegratedMeshLayer and IntegratedMesh3DTilesLayer are included. | |
toScreen
- Signature
-
toScreen (point: Point): ScreenPoint
Converts the given map point to a screen point.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| point | A point geometry. | |
- Returns
- ScreenPoint
The screen point corresponding to the given map point.
tryFatalErrorRecovery
- Signature
-
tryFatalErrorRecovery (): void
- Since
- ArcGIS Maps SDK for JavaScript 4.12
Call this method to clear any fatal errors resulting from a lost WebGL context.
- See also
- Returns
- void
Example
reactiveUtils.when( () => view.fatalError, () => view.tryFatalErrorRecovery()); when
- Signature
-
when <TResult1 = this, TResult2 = never>(onFulfilled?: OnFulfilledCallback<this, TResult1> | null | undefined, onRejected?: OnRejectedCallback<TResult2> | null | undefined): Promise<TResult1 | TResult2>
- Since
- ArcGIS Maps SDK for JavaScript 4.6
when() may be leveraged once an instance of the class is created. This method takes two input parameters: an onFulfilled function and an onRejected function.
The onFulfilled executes when the instance of the class loads. The
onRejected executes if the instance of the class fails to load.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| onFulfilled | OnFulfilledCallback<this, TResult1> | null | undefined | The function to call when the promise resolves. | |
| onRejected | The function to execute when the promise fails. | |
- Returns
- Promise<TResult1 | TResult2>
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 waylet 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
- Signature
-
whenAnalysisView <AnalysisType extends Analysis>(analysis: AnalysisType): Promise<AnalysisView3DFor<AnalysisType>>
- Type parameters
- <AnalysisType extends Analysis>
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 to analyses.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| analysis | AnalysisType | The analysis for which to obtain the analysis view. | |
- Returns
- Promise<AnalysisView3DFor>
Resolves to an instance of the analysis view for the provided analysis.
Example
// Create a slice analysislet analysis = new SliceAnalysis();
// add to the sceneviewview.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
- Signature
-
whenLayerView <TLayer extends Layer>(layer: TLayer): Promise<Layer extends TLayer ? LayerView : LayerView3DFor<TLayer>>
- Type parameters
- <TLayer extends Layer>
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).
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| layer | TLayer | The layer for which to obtain its LayerView. | |
- Returns
- Promise<Layer extends TLayer ? LayerView : LayerView3DFor>
Resolves to an instance of LayerView for the specified layer.
Examples
// Create a feature layer from a url pointing to a Feature Servicelet 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 });// Create a feature layer from a url pointing to a Feature Servicelet 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 });Events
| Name | Type |
|---|---|
analysis-view-create inherited | |
analysis-view-create-error inherited | |
analysis-view-destroy inherited | |
blur inherited | |
click inherited | |
double-click inherited | |
double-tap-drag inherited | |
drag inherited | |
focus inherited | |
hold inherited | |
immediate-click inherited | |
immediate-double-click inherited | |
key-down inherited | |
key-up inherited | |
layerview-create inherited | |
layerview-create-error inherited | |
layerview-destroy inherited | |
mouse-wheel inherited | |
pointer-down inherited | |
pointer-enter inherited | |
pointer-leave inherited | |
pointer-move inherited | |
pointer-up inherited | |
resize inherited | |
vertical-two-finger-drag inherited |
analysis-view-create
analysis-view-create: CustomEvent<AnalysisViewCreateEvent> - Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires when the view for an Analysis is created.
analysis-view-create-error
analysis-view-create-error: CustomEvent<AnalysisViewCreateErrorEvent> - Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires when an error occurs during the creation of an Analysis after an analysis is added to the view.
analysis-view-destroy
analysis-view-destroy: CustomEvent<AnalysisViewDestroyEvent> - Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires after an analysis view is destroyed.
blur
blur: CustomEvent<ViewBlurEvent> Fires when browser focus is moved away from the view.
click
click: CustomEvent<ClickEvent> - Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires after a user clicks on the view. This event emits slightly slower than an View.@immediate-click event to make sure that a View.@double-click event isn't triggered instead. The View.@immediate-click event can be used for responding to a click event without delay.
Examples
view.on("click", function(event){ // event is the event object returned after the event fires
// Prints the map coordinates of the clicked location console.log(event.mapPoint);});// Set up a click event handler and retrieve the screen pointview.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 });}); double-click
double-click: CustomEvent<DoubleClickEvent> - Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires after double-clicking on the view.
Example
view.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);}); double-tap-drag
double-tap-drag: CustomEvent<DoubleTapDragEvent> - Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires while the pointer is drag following a double-tap gesture on the view.
Example
view.on("double-tap-drag", (event) => { // Display the distance moved from the drag origin. console.log("x distance:", event.x, "y distance:", event.y);}); drag
drag: CustomEvent<DragEvent> - Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires during a pointer drag on the view.
Example
view.on("drag", function(event){ // Print out the current state of the // drag event. console.log("drag state", event.action);}); focus
focus: CustomEvent<ViewFocusEvent> Fires when browser focus is on the view.
hold
hold: CustomEvent<HoldEvent> - Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires after holding either a mouse button or a single finger on the view for a short amount of time.
Example
view.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);}); immediate-click
immediate-click: CustomEvent<ImmediateClickEvent> Fires right after a user clicks on the view. In contrast to the View.@click event,
the immediate-click event is emitted as soon as the user clicks on
the view, and is not inhibited by a View.@double-click event. This event
is useful for interactive experiences that require feedback without delay.
Example
// Set up an immediate-click event handler and retrieve the screen pointview.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);}); immediate-double-click
immediate-double-click: CustomEvent<ImmediateDoubleClickEvent> Is emitted after two consecutive View.@immediate-click events.
In contrast to View.@double-click, an immediate-double-click cannot
be prevented by use of stopPropagation on the View.@immediate-click
event and can therefore be used to react to double-clicking independently of usage of the
View.@immediate-click event.
key-down
key-down: CustomEvent<KeyDownEvent> - Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires after a keyboard key is pressed.
Example
// Zoom in when user clicks on "a" button// Zoom out when user clicks on "s" buttonview.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 }); }}); key-up
key-up: CustomEvent<KeyUpEvent> - Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires after a keyboard key is released.
layerview-create
layerview-create: CustomEvent<LayerViewCreateEvent> - Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires after each layer in the map has a corresponding LayerView created and rendered in the view.
- 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); }}); layerview-create-error
layerview-create-error: CustomEvent<LayerViewCreateErrorEvent> - Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires when an error occurs during the creation of a LayerView after a layer has been added to the map.
- See also
Example
// This function fires each time an error occurs during the creation of a layerviewview.on("layerview-create-error", function(event) { console.error("LayerView failed to create for layer with the id: ", event.layer.id);}); layerview-destroy
layerview-destroy: CustomEvent<LayerViewDestroyEvent> - Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires after a LayerView is destroyed and is no longer rendered in the view. This happens for example when a layer is removed from the map of the view.
mouse-wheel
mouse-wheel: CustomEvent<ViewMouseWheelEvent> - Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires when a wheel button of a pointing device (typically a mouse) is scrolled on the view.
Example
view.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);}); pointer-down
pointer-down: CustomEvent<PointerDownEvent> - Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires after a mouse button is pressed, or a finger touches the display.
pointer-enter
pointer-enter: CustomEvent<PointerEnterEvent> - Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires after a mouse cursor enters the view, or a display touch begins.
pointer-leave
pointer-leave: CustomEvent<PointerLeaveEvent> - Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires after a mouse cursor leaves the view, or a display touch ends.
pointer-move
pointer-move: CustomEvent<PointerMoveEvent> - Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires after the mouse or a finger on the display moves.
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);}); pointer-up
pointer-up: CustomEvent<PointerUpEvent> - Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires after a mouse button is released, or a display touch ends.
resize
resize: CustomEvent<ViewResizeEvent> - Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires when the view's size changes.
vertical-two-finger-drag
vertical-two-finger-drag: CustomEvent<VerticalTwoFingerDragEvent> - Since
- ArcGIS Maps SDK for JavaScript 5.0
Fires while the two pointers are dragged on the view.
Example
view.on("vertical-two-finger-drag", (event) => { // Display the distance moved vertically from the drag origin. console.log("y distance:", event.y);});






