Skip to content
ESM
import "@arcgis/map-components/components/arcgis-map";
Inheritance:
ArcgisMapPublicLitElement
Since
ArcGIS Maps SDK for JavaScript 4.28

The ArcGIS Map component is used to add 2D maps to web applications. For 3D maps, use the arcgis-scene.

Initializing the Map component

The Map component creates a MapView and can be initialized in one of three ways:

1. Using a WebMap

Load a WebMap from ArcGIS Online or an ArcGIS Enterprise portal by specifying the itemId attribute.

<arcgis-map item-id="05e015c5f0314db9a487a9b46cb37eca"></arcgis-map>
2. Setting Map component attributes directly

Define the Map component using attributes like basemap, center, and zoom directly.

<arcgis-map basemap="satellite" center="-154.88, 19.46" zoom="15"></arcgis-map>
3. Providing a Map instance

Alternatively, you can provide your own Map instance to the component. This allows full control over map configuration, including basemap, operational layers and spatialReference. See the Select features by rectangle sample for an example of this approach in action.

<arcgis-map></arcgis-map>
<script type="module">
const viewElement = document.querySelector("arcgis-map");
// set the basemap of the map to states feature layer
// add national parks feature layer and a polygon graphics layer
viewElement.map = new Map({
basemap: new Basemap({ baseLayers: [states] }),
layers: [nationalParksLayer, polygonGraphicsLayer]
});
// set the spatial reference of the map to NAD 1983 Albers contiguous USA
viewElement.spatialReference = { wkid: 102003 };
</script>

Adding components and customizing the Map

Other components can be added and connected to the Map component.

<arcgis-map item-id="05e015c5f0314db9a487a9b46cb37eca">
<arcgis-zoom slot="top-left"></arcgis-zoom>
<arcgis-legend slot="bottom-left"></arcgis-legend>
</arcgis-map>

The Map component can be customized further using any of the core API functionalities of the ArcGIS Maps SDK for JavaScript.

const viewElement = document.querySelector("arcgis-map");
viewElement.addEventListener("arcgisViewReadyChange", () => {
const layer = new GraphicsLayer({ title: "My Layer" });
viewElement.map.add(layer);
});

See also:

Demo

Properties

PropertyAttributeType
allLayerViews
readonly
animations-disabled
MapView["aria"]
attributionItems
readonly
MapView["attributionItems"]
attribution-mode
"dark" | "light" | null | undefined
auto-destroy-disabled
basemap
canZoomIn
readonly
canZoomOut
readonly
center
MapView["center"]
display-filter-disabled
MapView["extent"]
gamepad
readonly
ground
Ground
hide-attribution
interacting
readonly
itemId
reflected
item-id
layerViews
readonly
magnifier
readonly
map
navigating
readonly
popup-component-enabled
popup-disabled
popupElement
readonly
ready
readonly
resize-align
resolution
readonly
rotation
scale
selectionManager
readonly
spatial-reference-locked
stationary
readonly
suspended
readonly reflected
suspended
time-zone
updating
readonly
view
readonly
visibleArea
readonly
zoom

allLayerViews

readonly Property
Type
ReadonlyCollection<LayerView>

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

Property
Type
Collection<Analysis>
Since
ArcGIS Maps SDK for JavaScript 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);

animationsDisabled

Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 4.34

Indicates whether animations are disabled 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 true disables all animations in the view.

Attribute
animations-disabled
Default value
false

aria

Property
Type
MapView["aria"]
Since
ArcGIS Maps SDK for JavaScript 4.34

The ARIA attributes for the view container. Provides accessibility information to assistive technologies such as screen readers. Supports the following properties: label, description, describedByElements, and labelledByElements.

attributionItems

readonly Property
Type
MapView["attributionItems"]
Since
ArcGIS Maps SDK for JavaScript 5.0

The attribution items displayed in the view's attribution.

attributionMode

Property
Type
"dark" | "light" | null | undefined
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.

Attribute
attribution-mode

autoDestroyDisabled

Property
Type
boolean

If true, the component will not be destroyed automatically when it is disconnected from the document. This is useful when you want to move the component to a different place on the page, or temporarily hide it. If this is set, make sure to call the destroy() method when you are done to prevent memory leaks.

Attribute
auto-destroy-disabled
Default value
false

background

Property
Type
ColorBackground | null | undefined

The background color of the Map component.

Example
let view = new MapView({
container: "viewDiv",
map: map,
background: { // autocasts new ColorBackground()
color: "magenta" // autocasts as new Color()
}
});

basemap

Property
Type
Basemap | string | undefined

Specifies a basemap for the map. The basemap is a set of layers that give geographic context to the view and the other operational layers in the map. It can either be set using a basemap ID string (see values), Basemap or BasemapStyle.

Read more

Attribute
basemap

basemapView

Property
Type
BasemapView<LayerView>

Represents the view for a single basemap after it has been added to the map.

canZoomIn

readonly Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 5.0

Indicates if the view component can zoom in.

Default value
false

canZoomOut

readonly Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 5.0

Indicates if the view component can zoom out.

Default value
false

center

autocast Property
Type
MapView["center"]

Represents the view's center point; when setting the center, you may pass a Point instance, numbers representing a longitude/latitude pair ([-100.4593, 36.9014]), or a string attribute representing a longitude/latitude pair ("-100.4593, 36.9014"). Setting the center immediately changes the current view. For animating the view, see this component's goTo() method.

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 clone() method.

Notes

  • If the spatial reference of center set in the constructor does not match the spatialReference of the view, then the projectOperator will be loaded dynamically.
  • At runtime, the projectOperator must be loaded when setting the center to 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 isLoaded() method. If it is not yet loaded, you can call load() method.
Attribute
center
Examples
<arcgis-map zoom="4" center="-98, 39"></arcgis-map>
// Sets the initial center point of the map component to lon/lat coordinates
// lon/lat will be projected to match the spatial reference of the view
const viewElement = document.querySelector("arcgis-map");
viewElement.center = [-98, 39]; // lon, lat
// Updates the view's center point to a pre-determined Point object
let centerPoint = new Point({
x: 12804.24,
y: -1894032.09,
spatialReference: {
wkid: view.spatialReference // wkid 2027
}
});
const viewElement = document.querySelector("arcgis-map");
view.center = centerPoint;
// the point's spatialReference does not match the view's spatialReference
// the projectOperator will be used to project the point to match
// the view's spatialReference
const centerPoint = new Point({
x: -8746995,
y: 4352308,
spatialReference: {
wkid: 8857
}
});
if (!projectOperator.isLoaded()) {
await projectOperator.load();
}
const viewElement = document.querySelector("arcgis-map");
viewElement.center = centerPoint;

constraints

Property
Type
MapViewConstraints

Specifies constraints to scale, zoom, and rotation that may be applied to the map.

See also
Examples
view.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
}
});

displayFilterDisabled

Property
Type
boolean

Indicates whether a layer's displayFilterInfo is honored when rendering layers in the view. If false, display filters are ignored and all features are rendered.

Attribute
display-filter-disabled
Default value
false

extent

Property
Type
MapView["extent"]

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 this component's goTo() method. When the view is rotated, the extent does not update to include the newly visible portions of the map.

Notes

  • If the spatial reference of extent set does not match the spatialReference of the view, then the projectOperator will be loaded dynamically.
  • At runtime, the projectOperator must be loaded when setting the extent to 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 isLoaded() method. If it is not yet loaded, you can call the load method.

fatalError

Property
Type
Error<any> | null | undefined

A rejected view indicates a fatal error making it unable to display.

See also
Example
reactiveUtils.when(
() => view.fatalError,
() => {
console.error("Fatal Error! View has lost its WebGL context. Attempting to recover...");
view.tryFatalErrorRecovery();
}
);

floors

Property
Type
Collection<string>

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.

gamepad

readonly Property
Type
GamepadSettings

Gamepad input specific configuration settings.

graphics

Property
Type
Collection<Graphic>

Allows for adding graphics directly to the default graphics in the View.

See also
Examples
// Adds a graphic to the View
graphics.add(pointGraphic);
// Removes a graphic from the View
graphics.remove(pointGraphic);

ground

autocast Property
Type
Ground

Specifies the surface properties for the map.

See also
Attribute
ground
Examples
// Use the world elevation service
const map = new Map({
basemap: "topo-vector",
ground: "world-elevation"
});
// Create a map with the world elevation layer overlaid by a custom elevation layer
const worldElevation = new ElevationLayer({
url: "//elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"
});
const customElevation = new ElevationLayer({
url: "https://my.server.com/arcgis/rest/service/MyElevationService/ImageServer"
});
const map = new Map({
basemap: "topo-vector",
ground: new Ground({
layers: [ worldElevation, customElevation ]
})
});

hideAttribution

Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 5.0

Indicates whether the attribution is hidden 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 on terms of use, see the Terms of Use FAQ.

Attribute
hide-attribution
Default value
false

highlights

Property
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 nameDescriptionDefault settings
defaultThe 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}
temporaryThe 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 }
See also
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);

interacting

readonly Property
Type
boolean

Indicates whether the view is being interacted with (for example, when panning or via an interactive tool).

Default value
false

ipsInfo

Property
Type
IPSInfo | null | undefined
Since
ArcGIS Maps SDK for JavaScript 4.31

Contains indoor positioning system information for the map.

itemId

reflected Property
Type
null | undefined | string

The ID of a WebMap from ArcGIS Online or ArcGIS Enterprise portal.

To configure the portal url you must set the portalUrl property on config before the Map component loads.

Attribute
item-id

layerViews

readonly Property
Type
Collection<LayerView>

A collection containing a hierarchical list of all the created LayerViews of the operational layers in the map.

See also

loadErrorSources

Property
Type
LoadErrorSource[] | undefined
Since
ArcGIS Maps SDK for JavaScript 4.34

An array of objects that encountered an error while loading the component or any of its dependencies (e.g., basemap, ground, layers, tables). You may inspect the errors by accessing each object's loadError property.

magnifier

readonly Property
Type
Magnifier

The magnifier allows for showing a portion of the view as a magnifier image on top of the view.

map

Property
Type
Map | null | undefined

An instance of a Map object to display in the view.

readonly Property
Type
boolean

Indication whether the view is being navigated (for example when panning).

Default value
false
Property
Type
Navigation

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,
}
});

padding

Property
Type
ViewPadding

Padding to make the map's center and extent work off a subsection of the full map. This is particularly useful when layering UI elements or semi-transparent content on top of portions of the map.

See also
Default value
{left: 0, top: 0, right: 0, bottom: 0}
Property
Type
Popup | null | undefined

A Popup widget object that displays general content or attributes from layers in the map. Consider using the popupElement (beta), which represents the Popup component, instead.

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.

See also

popupComponentEnabled

Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 5.0
beta

Indicates whether the popup component (beta) is enabled as the default popup. When set to true, the popupElement property (representing the component) will be used for popups instead of the popup property (representing the widget).

Note: This is a beta feature and may change in future releases. At version 6.0, the Popup component will be used by default instead of the Popup widget and the popup-component-enabled attribute will no longer be necessary.

See also
Attribute
popup-component-enabled
Default value
false
Example
<arcgis-map item-id="WEBMAP-ID" popup-component-enabled></arcgis-map>

popupDisabled

Property
Type
boolean

Controls whether the default popup opens automatically when users click on the view. This controls both the popupElement and popup properties. When set to true, the popup will not open on click or when triggered programmatically.

See also
Attribute
popup-disabled
Default value
false

popupElement

readonly Property
Type
ArcgisPopup | null
Since
ArcGIS Maps SDK for JavaScript 5.0
beta

A reference to the current arcgis-popup (beta). The popupComponentEnabled property must be set to true to use this property.

Note: This is a beta feature and may change in future releases.

See also
Example
<arcgis-map item-id="WEBMAP-ID" popup-component-enabled></arcgis-map>
<script type="module">
const viewElement = document.querySelector("arcgis-map");
await viewElement.viewOnReady();
viewElement.popupElement.dockEnabled = true;
viewElement.popupElement.dockOptions = {
buttonEnabled: false,
breakpoint: false,
position: "top-right",
};
</script>

ready

readonly Property
Type
boolean

When true, this property indicates whether the view has successfully satisfied all dependencies, signaling that the following conditions are met:

When a view becomes ready it will resolve itself and invoke the callback defined in viewOnReady() where code can execute on a working view.

See also
Default value
false

resizeAlign

Property
Type
ResizeAlign

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.

Attribute
resize-align
Default value
"center"

resolution

readonly Property
Type
number

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.

rotation

Property
Type
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 the rotationEnabled property in constraints to false. See the code snippet below for an example of this.

Attribute
rotation
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
};

scale

Property
Type
number

Represents the map scale at the center of the view. Setting the scale immediately changes the view. For animating the view, see this component's goTo() method.

Attribute
scale

selectionManager

readonly Property
Type
SelectionManager
Since
ArcGIS Maps SDK for JavaScript 5.0
beta

The default SelectionManager for this view. Used to manage selections of features across layers.

spatialReference

Property
Type
SpatialReference

The spatial reference of the view. This indicates the projected or geographic coordinate system used to locate geographic features in the map. You can change the spatialReference of the view after it is initialized by either directly changing this property, or by changing the basemap from the arcgis-basemap-gallery and arcgis-basemap-toggle components. Set spatialReferenceLocked property to true to 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() method. 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

See also
Example
const viewElement = document.querySelector("arcgis-map");
// check if the projectOperator is loaded
if (!projectOperator.isLoaded()) {
// load the projectOperator if it is not loaded
projectOperator.load().then(() => {
// change the spatial reference of the map component to equal earth projection
viewElement.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
viewElement.spatialReference = new SpatialReference({
wkid: 54035 //equal earth projection
});
}

spatialReferenceLocked

Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 4.34

Indicates if the map's spatialReference can be changed after it is ready. The default is false, indicating the map's spatialReference can be changed at runtime. When true, basemaps with spatial references that do not match the map's spatial reference will be disabled in arcgis-basemap-gallery and arcgis-basemap-toggle components and the map's spatialReference cannot be changed at runtime.

Attribute
spatial-reference-locked
Default value
false

stationary

readonly Property
Type
boolean

Indication whether the view is animating, being navigated with or resizing.

Default value
false

suspended

readonlyreflected Property
Type
boolean

Indicates if the view is visible on the page.

Attribute
suspended
Default value
false

theme

Property
Type
Theme | null | undefined

This property specifies the base colors used by some components to render graphics and labels.

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]
});

timeExtent

Property
Type
TimeExtent | null | undefined

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")
}
});

timeZone

Property
Type
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.

See also
Attribute
time-zone
Default value
"system"
Example
// Date and time will be displayed in Pacific/Auckland (NZ) time zone
const view = new MapView({
map: map,
container: "viewDiv",
timeZone: "Pacific/Auckland"
});

updating

readonly Property
Type
boolean

Indicates whether the view is being updated by additional data requests to the network, or by processing received data.

Default value
false

view

readonly Property
Type
MapView

The MapView instance created and managed by the component. Accessible once the component is fully loaded.

viewpoint

Property
Type
Viewpoint

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 this component's goTo() method.

visibleArea

readonly Property
Type
Polygon | null | undefined
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. This is similar to the view MapView#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

zoom

Property
Type
number

Represents the level of detail (LOD) at the center of the map. A zoom level (or scale) is a number that defines how large or small the contents of a map appear in a Map component. 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 map has no LODs. When setting the zoom value, the component converts it to the corresponding scale, or interpolates it if the zoom is a fractional number.

Setting the zoom immediately changes the current view. For animating the view, see this component's goTo() method. Setting this property in conjunction with center is a convenient way to set the initial extent of the view.

Attribute
zoom

Methods

MethodSignature
closePopup(): Promise<void>
componentOnReady
inherited
componentOnReady(): Promise<this>
destroy(): Promise<void>
goTo(target: GoToTarget2D, options?: GoToOptions2D): Promise<unknown>
hitTest(screenPoint: MouseEvent | ScreenPoint, options?: HitTestOptions): Promise<ViewHitTestResult>
openPopup(options?: ViewPopupOpenOptions): Promise<void>
takeScreenshot(options?: UserSettings): Promise<Screenshot>
toMap(screenPoint: MouseEvent | ScreenPoint): Point
toScreen(point: Point, options?: ToScreenOptions2D): ScreenPoint | null | undefined
tryFatalErrorRecovery(): Promise<void>
viewOnReady(callback?: () => void, errback?: (error: Error) => void): Promise<void>
whenAnalysisView(analysis: Analysis): Promise<AnalysisView2DUnion>
whenLayerView<TLayer extends Layer>(layer: TLayer): Promise<LayerView2DFor<TLayer>>
zoomIn(): Promise<void>
zoomOut(): Promise<void>

closePopup

Method
Signature
closePopup (): Promise<void>

Closes the popup.

Returns
Promise<void>

componentOnReady

inherited Method
Signature
componentOnReady (): Promise<this>
Inherited from: PublicLitElement

Creates a promise that resolves once the component is fully loaded.

Returns
Promise<this>
Example
const arcgisMap = document.querySelector("arcgis-map");
document.body.append(arcgisMap);
await arcgisMap.componentOnReady();
console.log("arcgis-map is ready to go!");

destroy

Method
Signature
destroy (): Promise<void>

Destroys the view, and any associated resources, including its map, popup, and UI elements.

Returns
Promise<void>

goTo

Method
Signature
goTo (target: GoToTarget2D, options?: GoToOptions2D): Promise<unknown>

Sets the view to a given target.

Parameters
ParameterTypeDescriptionRequired
target
options
Returns
Promise<unknown>

hitTest

Method
Signature
hitTest (screenPoint: MouseEvent | ScreenPoint, options?: HitTestOptions): Promise<ViewHitTestResult>

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: FeatureLayer, CatalogLayer, CSVLayer, GeoJSONLayer, GeoRSSLayer, GraphicsLayer, KMLLayer, MapNotesLayer, OGCFeatureLayer, StreamLayer, SubtypeSublayer, VectorTileLayer, and WFSLayer.

The ParquetLayer hit result returns only the topmost feature when the hit occurs on overlapping features in a ParquetLayer.

The VectorTileLayer hit test result contains an array of objects containing a graphic. The graphic returns attributes of a style layer. In addition, the graphic's origin contains the style layer's id and layer index within the vector tile style. Spatial information about the actual feature represented in the style layer is returned only if the style layer is a symbol layer. Otherwise, the graphic's geometry is null.

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.

If the polygon feature's symbol style is set to none, the hitTest method will not return results when the fill is clicked. However, it will return results when the outline is clicked. To get results when clicking the fill, set the color to a transparent color instead.

Parameters
ParameterTypeDescriptionRequired
screenPoint
options
Returns
Promise<ViewHitTestResult>
Examples
viewElement.addEventListener("arcgisViewClick", (event) => {
viewElement.hitTest(event.detail).then((response) => {
const result = response.results[0];
if (result?.type === "graphic") {
const { longitude, latitude } = result.mapPoint;
console.log(`Hit graphic at (${longitude}, ${latitude})`, result.graphic);
} else {
console.log("Did not hit any graphic");
}
});
});
// get screenpoint from view's click event
viewElement.addEventListener("arcgisViewClick", async (event) => {
// Search for all media elements only on included mediaLayer at the clicked location
const response = await viewElement.hitTest(event.detail, {
include: {mediaLayer}
});
// if media elements are returned from the mediaLayer, do something with results
if (response.results.length){
// do something
console.log(response.results.length, "elements returned");
}
});

openPopup

Method
Signature
openPopup (options?: ViewPopupOpenOptions): Promise<void>

Opens the popup at the given location with content defined either explicitly with content or driven from the PopupTemplate of input features.

Parameters
ParameterTypeDescriptionRequired
options
Returns
Promise<void>

takeScreenshot

Method
Signature
takeScreenshot (options?: UserSettings): Promise<Screenshot>

Create a screenshot of the current view.

Parameters
ParameterTypeDescriptionRequired
options
Returns
Promise<Screenshot>

toMap

Method
Signature
toMap (screenPoint: MouseEvent | ScreenPoint): Point
Parameters
ParameterTypeDescriptionRequired
screenPoint
Returns
Point

toScreen

Method
Signature
toScreen (point: Point, options?: ToScreenOptions2D): ScreenPoint | null | undefined
Parameters
ParameterTypeDescriptionRequired
point
options
Returns
ScreenPoint | null | undefined

tryFatalErrorRecovery

Method
Signature
tryFatalErrorRecovery (): Promise<void>

Call this method to clear any fatal errors resulting from a lost WebGL context.

Returns
Promise<void>

viewOnReady

Method
Signature
viewOnReady (callback?: () => void, errback?: (error: Error) => void): Promise<void>
Since
ArcGIS Maps SDK for JavaScript 4.33

viewOnReady() may be leveraged once an instance of the component and its underlying view is created and ready. This method takes two input parameters, a callback function and an errback function, and returns a promise. The callback executes when the promise resolves, and the errback executes if the promise is rejected.

See also
Parameters
ParameterTypeDescriptionRequired
callback
() => void
errback
(error: Error) => void
Returns
Promise<void>
Example
const viewElement = document.querySelector("arcgis-map");
await viewElement.viewOnReady();
// The view is now ready to be used.
viewElement.map.add(new FeatureLayer({...}));

whenAnalysisView

Method
Signature
whenAnalysisView (analysis: Analysis): Promise<AnalysisView2DUnion>
Since
ArcGIS Maps SDK for JavaScript 4.34

Gets the analysis view created for the given analysis object.

Read more

Parameters
ParameterTypeDescriptionRequired
analysis
Returns
Promise<AnalysisView2DUnion>

whenLayerView

Method
Signature
whenLayerView <TLayer extends Layer>(layer: TLayer): Promise<LayerView2DFor<TLayer>>
Type parameters
<TLayer extends Layer>

Gets the LayerView created on the view for the given layer.

Read more

Parameters
ParameterTypeDescriptionRequired
layer
TLayer
Returns
Promise<LayerView2DFor>

zoomIn

Method
Signature
zoomIn (): Promise<void>
Since
ArcGIS Maps SDK for JavaScript 5.0

Zooms in the view component by a factor of 2.

Returns
Promise<void>

zoomOut

Method
Signature
zoomOut (): Promise<void>
Since
ArcGIS Maps SDK for JavaScript 5.0

Zooms out the view component by a factor of 2.

Returns
Promise<void>

Events

arcgisLoadError

Event
arcgisLoadError: CustomEvent<void>
Since
ArcGIS Maps SDK for JavaScript 4.34

Fires when an arcgis-map fails to load or if one of its dependencies fails to load (e.g., basemap, ground, layers).

See also
bubbles composed cancelable
Example
viewElement.addEventListener("arcgisLoadError", () => {
console.log(viewElement.loadErrorSources);
});

arcgisViewAnalysisViewCreate

Event
arcgisViewAnalysisViewCreate: CustomEvent<AnalysisViewCreateEvent>
Since
ArcGIS Maps SDK for JavaScript 4.34

Fires when the view for an analysis is created.

Read more

bubbles composed cancelable

arcgisViewAnalysisViewCreateError

Event
arcgisViewAnalysisViewCreateError: CustomEvent<AnalysisViewCreateErrorEvent>
Since
ArcGIS Maps SDK for JavaScript 4.34

Fires when an error occurs during the creation of an analysis view after an analysis is added to the view.

Read more

bubbles composed cancelable

arcgisViewAnalysisViewDestroy

Event
arcgisViewAnalysisViewDestroy: CustomEvent<AnalysisViewDestroyEvent>
Since
ArcGIS Maps SDK for JavaScript 4.34

Fires after an analysis view is destroyed.

Read more

bubbles composed cancelable

arcgisViewChange

Event
arcgisViewChange: CustomEvent<void>

This event is triggered when view-related properties change, such as zoom, scale, center, rotation, extent, viewpoint, or stationary. It reflects user interactions (e.g. panning or zooming) or programmatic updates to the view.

bubbles composed cancelable
Example
// get the number of features in a layer view whenever the view becomes stationary
viewElement.addEventListener("arcgisViewChange", async (event) =>{
if (viewElement.stationary) {
// Returns number of features available for drawing in a given layer view
const count = await layerView.queryFeatureCount({
geometry: viewElement.extent
});
// use the features count
}
});

arcgisViewClick

Event
arcgisViewClick: CustomEvent<ClickEvent>

Fires after a user clicks on the view. This event emits slightly slower than an @arcgisViewImmediateClick event to make sure that an @arcgisViewDoubleClick event isn't triggered instead. The arcgisViewImmediateClick event can be used for responding to an arcgisViewClick event without delay.

bubbles composed cancelable
Example
// Listen for clicks on the view and perform a hit test on a feature layer
viewElement.addEventListener("arcgisViewClick", (event) => {
// Return hit test results from the feature layer
// where it intersects the screen coordinates from the click event.
// The result is a polygon representing the state that was clicked.
viewElement.hitTest(event.detail).then((response) => {
if (response.results.length) {
const stateBoundaryPolygon = response.results.find((result) => {
return result.graphic.layer === stateBoundaryFeatureLayer;
}).graphic.geometry;
getPolygonCentroid(stateBoundaryPolygon);
}
});
});

arcgisViewDoubleClick

Event
arcgisViewDoubleClick: CustomEvent<DoubleClickEvent>

Fires after double-clicking on the view.

bubbles composed cancelable
Example
viewElement.addEventListener("arcgisViewDoubleClick", async (event) => {
// Prevent the default zoom-in behavior on double-click
event.detail.stopPropagation();
});

arcgisViewDoubleTapDrag

Event
arcgisViewDoubleTapDrag: CustomEvent<DoubleTapDragEvent>
Since
ArcGIS Maps SDK for JavaScript 5.0

Fires while the pointer is dragged following a double-tap gesture on the view.

Read more

bubbles composed cancelable
Example
viewElement.addEventListener("arcgisViewDoubleTapDrag", (event) => {
// Display the distance moved from the drag origin.
console.log("x distance:", event.detail.x, "y distance:", event.detail.y);
});

arcgisViewDrag

Event
arcgisViewDrag: CustomEvent<DragEvent>

Fires during a pointer drag on the view.

bubbles composed cancelable

arcgisViewHold

Event
arcgisViewHold: CustomEvent<HoldEvent>

Fires after holding either a mouse button or a single finger on the view for a short amount of time.

bubbles composed cancelable

arcgisViewImmediateClick

Event
arcgisViewImmediateClick: CustomEvent<ImmediateClickEvent>

Fires right after a user clicks on the view. In contrast to the @arcgisViewClick event, the arcgisViewImmediateClick is emitted as soon as the user clicks on the view, and is not inhibited by a @arcgisViewDoubleClick event. This event is useful for interactive experiences that require feedback without delay.

bubbles composed cancelable
Example
viewElement.addEventListener("arcgisViewImmediateClick", async (event) => {
// Prevent the default zoom-in behavior on arcgisViewImmediateClick
event.detail.stopPropagation();
});

arcgisViewImmediateDoubleClick

Event
arcgisViewImmediateDoubleClick: CustomEvent<ImmediateDoubleClickEvent>

Fires after two consecutive @arcgisViewImmediateClick events. In contrast to @arcgisViewDoubleClick, an arcgisViewImmediateDoubleClick cannot be prevented by use of stopPropagation() on the @arcgisViewImmediateClick event and can therefore be used to react to double-clicking independently of usage of the @arcgisViewImmediateClick event.

bubbles composed cancelable

arcgisViewKeyDown

Event
arcgisViewKeyDown: CustomEvent<KeyDownEvent>

Fires after a keyboard key is pressed.

bubbles composed cancelable
Example
// Disable zooming with the keyboard
// Stop event propagation when `+` and `-` keys are pressed.
viewElement.addEventListener("arcgisViewKeyDown", function(event){
console.log("key-down", event);
const prohibitedKeys = ["+", "-"];
const keyPressed = event.detail.key;
if (prohibitedKeys.indexOf(keyPressed) !== -1) {
event.detail.stopPropagation();
}
});

arcgisViewKeyUp

Event
arcgisViewKeyUp: CustomEvent<KeyUpEvent>

Fires after a keyboard key is released.

bubbles composed cancelable

arcgisViewLayerviewCreate

Event
arcgisViewLayerviewCreate: CustomEvent<LayerViewCreateEvent>

Fires after each layer in the map has a corresponding LayerView created and rendered in the view.

bubbles composed cancelable

arcgisViewLayerviewCreateError

Event
arcgisViewLayerviewCreateError: CustomEvent<LayerViewCreateErrorEvent>

Fires when an error occurs during the creation of a LayerView after a layer has been added to the map.

bubbles composed cancelable

arcgisViewLayerviewDestroy

Event
arcgisViewLayerviewDestroy: CustomEvent<LayerViewDestroyEvent>

Fires after a LayerView is destroyed and is no longer rendered in the view.

bubbles composed cancelable

arcgisViewMouseWheel

Event
arcgisViewMouseWheel: CustomEvent<ViewMouseWheelEvent>

Fires when a wheel button of a pointing device (typically a mouse) is scrolled on the view.

bubbles composed cancelable
Example
viewElement.addEventListener("arcgisViewMouseWheel", async (event) => {
// Prevent the default zoom-in and zoom-out behavior on arcgisViewMouseWheel
event.detail.stopPropagation();
});

arcgisViewPointerDown

Event
arcgisViewPointerDown: CustomEvent<PointerDownEvent>

Fires after a mouse button is pressed, or a finger touches the display.

See also
bubbles composed cancelable

arcgisViewPointerEnter

Event
arcgisViewPointerEnter: CustomEvent<PointerEnterEvent>

Fires after a mouse cursor enters the view, or a display touch begins.

bubbles composed cancelable

arcgisViewPointerLeave

Event
arcgisViewPointerLeave: CustomEvent<PointerLeaveEvent>

Fires after a mouse cursor leaves the view, or a display touch ends.

bubbles composed cancelable

arcgisViewPointerMove

Event
arcgisViewPointerMove: CustomEvent<PointerMoveEvent>

Fires after the mouse or a finger on the display moves.

See also
bubbles composed cancelable

arcgisViewPointerUp

Event
arcgisViewPointerUp: CustomEvent<PointerUpEvent>

Fires after a mouse button is released, or a display touch ends.

bubbles composed cancelable

arcgisViewReadyChange

Event
arcgisViewReadyChange: CustomEvent<void>

This event is for the ready property and is emitted when the view is ready. Fires also when the map is updated.

bubbles composed cancelable

arcgisViewReadyError

Event
arcgisViewReadyError: CustomEvent<void>
Since
ArcGIS Maps SDK for JavaScript 4.34

Fires if the view encounters a content or rendering error.

bubbles composed cancelable
Example
viewElement.addEventListener("arcgisViewReadyError", () => {
// handle error
});

arcgisViewVerticalTwoFingerDrag

Event
arcgisViewVerticalTwoFingerDrag: CustomEvent<VerticalTwoFingerDragEvent>
Since
ArcGIS Maps SDK for JavaScript 5.0

Fires while the two pointers are dragged vertically on the view.

Read more

bubbles composed cancelable
Example
viewElement.addEventListener("arcgisViewVerticalTwoFingerDrag", (event) => {
// Display the distance moved vertically from the drag origin.
console.log("y distance:", event.detail.y);
});

Slots

NameDescription

Default slot for adding components to the map. User is responsible for positioning the content via CSS.

Slot for components positioned in the top-left corner.

Slot for components positioned in the top-right corner.

Slot for components positioned in the bottom-left corner.

Slot for components positioned in the bottom-right corner.

Slot for components positioned at the top-start (top-left in LTR, top-right in RTL).

Slot for components positioned at the top-end (top-right in LTR, top-left in RTL).

Slot for components positioned at the bottom-start (bottom-left in LTR, bottom-right in RTL).

Slot for components positioned at the bottom-end (bottom-right in LTR, bottom-left in RTL).

Slot for the arcgis-popup component to open automatically on click. Only the Popup component can be placed in this slot.

Styles

NameDefaultDescription

Since 4.34 Specifies the top padding for the layout.

Since 4.34 Specifies the bottom padding for the layout.

Since 4.34 Specifies the left padding for the layout.

Since 4.34 Specifies the right padding for the layout.

Since 5.0 Specifies the focus outline color for the view.