# Class MapExtension

Extends the capabilities of an Esri Map object.

#### Hierarchy (view full)

- EntityBase<MapExtensionProperties>
  - MapExtension

#####
Index

### Constructors

constructor

### Properties

_deserializedMapPromise
_deserializedViewMode
_deserializedViewModePromise
_handles
_id
_isSwitchingMap
_itemType
_map
_scene
@eventTypes
allLayerExtensions
constraints
formatSettings
onClick?
onHover?
onHoverEnd?
onInitialized?
onViewpointChanged?
tableExtensions

### Accessors

_spatialReference
basemapExtension
basemapOptions
bookmarks
contextMenu
failureMode
groundExtension
id
initialBasemapExtension
initialLayerPreset
initialViewMode
isDestroyed
isInitialized
isSwitchingMap
itemType
layerExtensions
map
requestHelper
title
viewMode
webMap
webMapItemTitle
webScene
webSceneItemTitle

### Methods

_applyMapProperties
_createFormatSettings
_createLayerExtensionCollection
_createMap
_createScene
_createTableExtensionCollection
_getSerializableProperties
_initializableChildCollections
_initializeChildren
_onDestroy
_onInitialize
_postInitialize
_toPropertyDef
assignProperties
assignPropertiesAsync
destroy
finishAssignProperties
getAllFeatureSources
getDefault
getDefaults
getSerializableProperties
initialize
isSupportedViewMode
setWebMap
setWebScene
switchMap
switchViewMode
toItemUri
toJSON

##
Constructors

### constructor

- new MapExtension(properties?): MapExtension

- #### Parameters

  - `Optional` properties: MapExtensionProperties

  #### Returns MapExtension

  Overrides EntityBase.constructor

##
Properties

### `Protected`_deserializedMapPromise

_deserializedMapPromise: Promise<void>

The Promise created when the 'map' property is deserialized.

### `Protected`_deserializedViewMode

_deserializedViewMode: ViewMode

The viewMode value deserialized from a saved project.

### `Protected`_deserializedViewModePromise

_deserializedViewModePromise: Promise<void>

The Promise created to switch viewModes when a saved project is loaded.

### `Protected` `Readonly`_handles

_handles: Handles<unknown, ResourceHandle>

Inherited from EntityBase._handles

### `Protected`_id

_id: string

The unique ID for this entity. Once set, this should never change.

Inherited from EntityBase._id

### `Protected`_isSwitchingMap

_isSwitchingMap: boolean = false

Indicates that the extension is in the process of switching maps.

### `Protected` `Readonly`_itemType

_itemType: string = ItemType.MAP_EXTENSION

The item type for this entity when it participates in an App.

Overrides EntityBase._itemType

### `Protected`_map

_map: Map

The underlying WebMap instance created from mapping/MapExtension!MapExtension.webMap.

### `Protected`_scene

_scene: WebScene

The underlying WebScene instance created from mapping/MapExtension!MapExtension.webScene.

### @eventTypes

@eventTypes: MapExtensionEvents

#### Deprecated

Do not directly reference this property. Use EventNames and EventTypes helpers from @arcgis/core/Evented.

Overrides EntityBase.@eventTypes

### `Readonly` allLayerExtensions

allLayerExtensions: LayerExtensionCollection<LayerExtensionProperties>

A flat collection of all the layers extensions in the map. This collection contains extensions for basemap layers, operational layers and ground layers. Extensions for group layers and their children are also part of this collection. This collection is read-only.

### `Readonly` constraints

constraints: MapConstraints

Configured constraints for the map. Note that it is the caller's responsibility to set these constraints on any MapView or SceneView instances that are created.

### `Readonly` formatSettings

formatSettings: FormatSettings

Settings that affect how values in this mapping/MapExtension!MapExtension are formatted.

### `Optional` onClick

onClick?: Action

An action that will be performed when the user clicks on the map.

### `Optional` onHover

onHover?: Action

An action that will be performed when the user hovers over the map.

### `Optional` onHoverEnd

onHoverEnd?: Action

An action that will be performed when the user stops hovering over the map.

### `Optional` onInitialized

onInitialized?: Action

An action that will be performed when the map initializes.

### `Optional` onViewpointChanged

onViewpointChanged?: Action

An action that will be performed when the viewpoint changes.

### `Readonly` tableExtensions

tableExtensions: TableExtensionCollection

The table extensions associated with each table in the map.

##
Accessors

### `Protected`_spatialReference

- get _spatialReference(): SpatialReference

- Gets the spatial reference of the map.

  #### Returns SpatialReference

### basemapExtension

- get basemapExtension(): BasemapExtension<BasemapExtensionProperties>

- The basemap extension associated with the map's basemap object.

  #### Returns BasemapExtension<BasemapExtensionProperties>

- set basemapExtension(value): void

- #### Parameters

  - value: BasemapExtension<BasemapExtensionProperties>

  #### Returns void

### basemapOptions

- get basemapOptions(): Collection<BasemapExtension<BasemapExtensionProperties>>

- Basemaps that are suitable for use with this map. Can be used to populate a basemap picker.

  #### Returns Collection<BasemapExtension<BasemapExtensionProperties>>

### bookmarks

- get bookmarks(): Collection<Bookmark>

- Bookmarked locations on this map.

  #### Returns Collection<Bookmark>

### contextMenu

- get contextMenu(): Menu<MenuItemProperties, MenuProperties, MenuItem<MenuItemProperties, MenuProperties>>

- A menu for actions that can be performed with the map.

  #### Returns Menu<MenuItemProperties, MenuProperties, MenuItem<MenuItemProperties, MenuProperties>>

- set contextMenu(value): void

- #### Parameters

  - value: Menu<MenuItemProperties, MenuProperties, MenuItem<MenuItemProperties, MenuProperties>>

  #### Returns void

### failureMode

- get failureMode(): FailureMode

- Determines how a parent object should handle initialization failure in this object. The default is "warn".

  - `"error"`: support/InitializeError!InitializeError is thrown.
  - `"warn"`: Message is logged and support/InitializableBase!InitializeWarningEvent is raised.
  - `"ignore"`: support/InitializableBase!InitializeWarningEvent is raised.

  #### Returns FailureMode

  Inherited from EntityBase.failureMode

- set failureMode(value): void

- #### Parameters

  - value: FailureMode

  #### Returns void

  Inherited from EntityBase.failureMode

### groundExtension

- get groundExtension(): GroundExtension

- The ground extension associated with the map's ground object.

  #### Returns GroundExtension

- set groundExtension(value): void

- #### Parameters

  - value: GroundExtension

  #### Returns void

### id

- get id(): string

- The unique ID for this entity.

  #### Returns string

  Inherited from EntityBase.id

### initialBasemapExtension

- get initialBasemapExtension(): BasemapExtension<BasemapExtensionProperties>

- The extension for the map's initial basemap.

  #### Returns BasemapExtension<BasemapExtensionProperties>

### initialLayerPreset

- get initialLayerPreset(): LayerPreset

- The layer-preset/LayerPreset!LayerPreset applied to the MapExtension on construction.

  #### Returns LayerPreset

- set initialLayerPreset(layerPreset): void

- #### Parameters

  - layerPreset: LayerPreset

  #### Returns void

### initialViewMode

- get initialViewMode(): ViewMode

- The initial view mode for the map (2D or 3D).

  #### Returns ViewMode

- set initialViewMode(viewMode): void

- #### Parameters

  - viewMode: ViewMode

  #### Returns void

### isDestroyed

- get isDestroyed(): boolean

- See support/InitializableBase!Initializable.isDestroyed.

  #### Returns boolean

  Inherited from EntityBase.isDestroyed

### isInitialized

- get isInitialized(): boolean

- See support/InitializableBase!Initializable.isInitialized.

  #### Returns boolean

  Inherited from EntityBase.isInitialized

### isSwitchingMap

- get isSwitchingMap(): boolean

- Indicates that the extension is in the process of switching maps.

  #### Returns boolean

### itemType

- get itemType(): string

- The item type for this entity when it participates in an App.

  #### Returns string

  Inherited from EntityBase.itemType

### layerExtensions

- get layerExtensions(): LayerExtensionCollection<LayerExtensionProperties>

- The layer extensions associated with each layer of the map.

  #### Returns LayerExtensionCollection<LayerExtensionProperties>

### map

- get map(): Map

- The Esri Map object being extended.

  #### Returns Map

### requestHelper

- get requestHelper(): ArcGISRequestHelper

- The utilities/RequestHelper!RequestHelper to use when making requests to external services. If not specified, support/ArcGISRequestHelper!ArcGISRequestHelper will be used.

  #### Returns ArcGISRequestHelper

- set requestHelper(requestHelper): void

- #### Parameters

  - requestHelper: ArcGISRequestHelper

  #### Returns void

### title

- get title(): string

- A human-readable title for the map.

  #### Returns string

- set title(value): void

- #### Parameters

  - value: string

  #### Returns void

### viewMode

- get viewMode(): ViewMode

- The current view mode for the map (2D or 3D).

  #### Returns ViewMode

### webMap

- get webMap(): WebMapLike

- When present, mapping/MapExtension!MapExtension.map will be loaded from the given web map in Portal when the view mode is 2D. The web map can be specified either as a PortalItem object, or simply using the portal item ID.

  #### Returns WebMapLike

### webMapItemTitle

- get webMapItemTitle(): string

- The title of the web map portal item.

  #### Returns string

### webScene

- get webScene(): WebSceneLike

- When present, mapping/MapExtension!MapExtension.map will be loaded from the given web scene in Portal when the view mode is 3D. The web scene can be specified either as a PortalItem object, or simply using the portal item ID.

  #### Returns WebSceneLike

### webSceneItemTitle

- get webSceneItemTitle(): string

- The title of the web scene portal item.

  #### Returns string

##
Methods

### `Protected`_applyMapProperties

- _applyMapProperties(mapProperties, map, portalItem?): Promise<void>

- Invoked when web map/web scene json needs to be applied to the Map object.

  #### Parameters

  - mapProperties: MapProperties

    The properties to apply.

  - map: Map

    The map/scene to apply the properties to.

  - `Optional` portalItem: PortalItem

    Portal item that the properties came from, if applicable.

  #### Returns Promise<void>

### `Protected`_createFormatSettings

- _createFormatSettings(): FormatSettings

- Invoked to create FormatSettings.

  #### Returns FormatSettings

### `Protected`_createLayerExtensionCollection

- _createLayerExtensionCollection(): LayerExtensionCollectionBase

- Invoked to create a LayerExtensionCollection.

  #### Returns LayerExtensionCollectionBase

### `Protected`_createMap

- _createMap(): Promise<void>

- Creates the 2D map from the webMap if it's not already created.

  #### Returns Promise<void>

### `Protected`_createScene

- _createScene(): Promise<void>

- Creates the 3D scene from the webScene if it's not already created.

  #### Returns Promise<void>

### `Protected`_createTableExtensionCollection

- _createTableExtensionCollection(): TableExtensionCollection

- Invoked to create a TableExtensionCollection.

  #### Returns TableExtensionCollection

### `Protected`_getSerializableProperties

- _getSerializableProperties(): PropertyDefs<MapExtensionProperties>

- The property keys and their metadata that are used to implement serializing and deserializing the class instance.

  #### Returns PropertyDefs<MapExtensionProperties>

  Overrides EntityBase._getSerializableProperties

### `Protected`_initializableChildCollections

- _initializableChildCollections(): IterableIterator<Collection<InitializableBase<InitializableBaseProperties>>, any, any>

- Collections of child items to initialize. Items that fail to initialize are removed from the collection.

  #### Returns IterableIterator<Collection<InitializableBase<InitializableBaseProperties>>, any, any>

  Overrides EntityBase._initializableChildCollections

### `Protected`_initializeChildren

- _initializeChildren(): Promise<void>

- Initializes child entities.

  #### Returns Promise<void>

  Inherited from EntityBase._initializeChildren

### `Protected`_onDestroy

- _onDestroy(): Promise<void>

- Called to perform cleanup. Subclasses should override this method rather than destroy() to perform custom cleanup.

  #### Returns Promise<void>

  Overrides EntityBase._onDestroy

### `Protected`_onInitialize

- _onInitialize(): Promise<void>

- Called to perform initialization of the support/InitializableBase!InitializableBase. Subclasses should override this method rather than initialize() to perform custom initialization.

  #### Returns Promise<void>

  Overrides EntityBase._onInitialize

### `Protected`_postInitialize

- _postInitialize(): Promise<void>

- Called after normal initialization. Note: Child items are initialized before this is called.

  #### Returns Promise<void>

  Overrides EntityBase._postInitialize

### `Protected`_toPropertyDef

- _toPropertyDef<T>(def): PropertyDef<T>

- Converts the value to a PropertyDef object.

  #### Type Parameters

  - T

  #### Parameters

  - def: PropertyDefSerializeMode | PropertyDefSerializeMode[] | PropertyDef<T>

    The value to convert.

  #### Returns PropertyDef<T>

  Inherited from EntityBase._toPropertyDef

### assignProperties

- assignProperties(properties): void

- #### Parameters

  - properties: Partial<MapExtensionProperties>

  #### Returns void

  #### Inherit Doc

  Inherited from EntityBase.assignProperties

### assignPropertiesAsync

- assignPropertiesAsync(properties): Promise<void>

- #### Parameters

  - properties: Partial<MapExtensionProperties>

  #### Returns Promise<void>

  #### Inherit Doc

  Inherited from EntityBase.assignPropertiesAsync

### destroy

- destroy(): Promise<void>

- A clean-up function that should get called whenever the item is disposed of.

  #### Returns Promise<void>

  Inherited from EntityBase.destroy

### finishAssignProperties

- finishAssignProperties(): Promise<void>

- #### Returns Promise<void>

  #### Inherit Doc

  Inherited from EntityBase.finishAssignProperties

### getAllFeatureSources

- getAllFeatureSources(predicate?): FeatureSource[]

- Gets a flattened list of all feature sources for the associated map.

  #### Parameters

  - predicate: FeatureSourcePredicate = ...

    If specified, only sources that match the given predicate will be returned.

  #### Returns FeatureSource[]

### getDefault

- getDefault<K>(key): MapExtensionProperties[K]

- #### Type Parameters

  - K extends keyof MapExtensionProperties

  #### Parameters

  - key: K

  #### Returns MapExtensionProperties[K]

  #### Inherit Doc

  Inherited from EntityBase.getDefault

### getDefaults

- getDefaults(): MapExtensionProperties

- #### Returns MapExtensionProperties

  #### Inherit Doc

  Overrides EntityBase.getDefaults

### getSerializableProperties

- getSerializableProperties(serializeMode?): PropertyDefs<MapExtensionProperties>

- Returns the serializable properties.

  #### Parameters

  - `Optional` serializeMode: SerializeMode

    Optional. If specified, only properties that support the given serialization mode will be returned.

  #### Returns PropertyDefs<MapExtensionProperties>

  Inherited from EntityBase.getSerializableProperties

### initialize

- initialize(): Promise<void>

- Initializes the item.

  #### Returns Promise<void>

  Inherited from EntityBase.initialize

### isSupportedViewMode

- isSupportedViewMode(viewMode): boolean

- Determines whether this map extension supports the given view mode.

  #### Parameters

  - viewMode: ViewMode

    The view mode to check.

  #### Returns boolean

### setWebMap

- setWebMap(webMap): Promise<void>

- Updates the map that will load when the view mode is switched to MAP.

  #### Parameters

  - webMap: WebMapLike

    The web map to set.

  #### Returns Promise<void>

### setWebScene

- setWebScene(webScene): Promise<void>

- Updates the map that will load when the view mode is switched to SCENE.

  #### Parameters

  - webScene: WebSceneLike

    The web scene to set.

  #### Returns Promise<void>

### switchMap

- switchMap(newMap): Promise<void>

- Switches the current map for a new one. This operation will reconfigure existing layer, sublayer, and table extensions to extend the equivalent ones in the new map, if possible.

  The primary use case is for switching between maps that have a similar configuration, for example when going between a map and a scene with similar layers.

  #### Parameters

  - newMap: Map

    The new map.

  #### Returns Promise<void>

### switchViewMode

- switchViewMode(viewMode): Promise<void>

- Switches the map extension's view mode.

  #### Parameters

  - viewMode: ViewMode

    The view mode to switch to.

  #### Returns Promise<void>

### toItemUri

- toItemUri(): string

- Creates an item:// URI reference to this entity.

  #### Returns string

  Inherited from EntityBase.toItemUri

### toJSON

- toJSON(serializeMode?): MapExtensionProperties

- #### Parameters

  - serializeMode: SerializeMode = "all"

  #### Returns MapExtensionProperties

  #### Inherit Doc

  Inherited from EntityBase.toJSON