UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

170 lines (168 loc) 9.6 kB
import type WebDocument2D from "./WebDocument2D.js"; import type Collection from "./core/Collection.js"; import type Version from "./core/Version.js"; import type UtilityNetwork from "./networks/UtilityNetwork.js"; import type GeotriggersInfo from "./webdoc/GeotriggersInfo.js"; import type IPSInfo from "./webdoc/IPSInfo.js"; import type { WebDocument2DProperties } from "./WebDocument2D.js"; import type { GeotriggersInfoProperties } from "./webdoc/GeotriggersInfo.js"; import type { IPSInfoProperties } from "./webdoc/IPSInfo.js"; import type { UtilityNetworkProperties } from "./networks/UtilityNetwork.js"; import type { ReadonlyArrayOrCollection } from "./core/Collection.js"; export interface WebMapProperties extends WebDocument2DProperties, Partial<Pick<WebMap, "presentation">> { /** * Information relating to a list of Geotriggers. * * @since 4.24 */ geotriggersInfo?: GeotriggersInfoProperties | null; /** * Contains indoor positioning system information for the map. * * @since 4.31 */ ipsInfo?: IPSInfoProperties | null; /** The utilityNetworks object contains a collection of [UtilityNetworks](https://developers.arcgis.com/javascript/latest/references/core/networks/UtilityNetwork/) saved on the web map. */ utilityNetworks?: ReadonlyArrayOrCollection<UtilityNetworkProperties> | null; } /** * Loads a [WebMap](https://doc.arcgis.com/en/arcgis-online/create-maps/make-your-first-map.htm) * from [ArcGIS Online](https://www.arcgis.com/home/) or * [ArcGIS Enterprise portal](https://enterprise.arcgis.com/en/portal/latest/administer/windows/what-is-portal-for-arcgis-.htm) * into a [MapView](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/). It defines the content, style, and bookmarks of your webmap, and it can be shared * across multiple ArcGIS web and desktop applications. The webmap is saved as a JSON document that can be consumed by the * ArcGIS Maps SDK for JavaScript via the WebMap class to easily create compelling 2D applications. The JSON document is written * according to the [webmap specification](https://developers.arcgis.com/web-map-specification/). Although you can easily create your own webmaps, * there are many sample [webmaps in ArcGIS Online](https://webmaps.maps.arcgis.com/home/group.html?id=bf19f0a0871649c49f6743dbe8138ecb) * that you can use to get started with the API. You may modify or add new content to these webmaps. * * To load a WebMap from ArcGIS Online into a MapView, you must reference the ID of the webmap in the * [portalItem](https://developers.arcgis.com/javascript/latest/references/core/WebMap/#portalItem) property of this class. * * ```js * const webmap = new WebMap({ * portalItem: { // autocasts as new PortalItem() * id: "e691172598f04ea8881cd2a4adaa45ba" * } * }); * ``` * * To load a Webmap from an on-premise portal, set the portal * url in [esriConfig.portalUrl](https://developers.arcgis.com/javascript/latest/references/core/config/#Config-portalUrl). * * ```js * esriConfig.portalUrl = "https://myHostName.esri.com/arcgis"; * * const webmap = new WebMap({ * portalItem: { // autocasts as new PortalItem() * id: "f701172599f04ea8781de2a4adzz46ab" * } * }); * ``` * * Then you must reference the WebMap instance in the `map` property of the view. * * ```js * const view = new MapView({ * map: webmap, // The WebMap instance created above * container: "viewDiv" * }); * ``` * * > [!WARNING] * > * > **Known Limitations** * > * > [WCSLayers](https://developers.arcgis.com/javascript/latest/references/core/layers/WCSLayer/) are currently not supported. [WFSLayers](https://developers.arcgis.com/javascript/latest/references/core/layers/WFSLayer/) must be from a WFS 2.0.0 service and have GeoJSON output format enabled. * > In instances when the webmap contains layer types that are not yet supported in the API, layers will be created as an [UnsupportedLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/UnsupportedLayer/). * > This layer type is used specifically in these instances where the layer may exist in a given WebMap (e.g. WFS layer from WFS 1.0.0), but may not be currently supported in the version of the * > API accessing it. * > An [UnknownLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/UnknownLayer/) will be used if future versions of the WebMap contains a new type of layer. The API version may not recognize this layer type, therefore * > it would come across as an [UnknownLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/UnknownLayer/). * > * > Embedded Routes * > * Prior to the ArcGIS Online 8.1 release (March 2020) when copying a route layer * > from an item to be stored inside a WebMap it would be stored as an embedded feature * > collection, and inadvertently not attributed as a route. When these webmaps are loaded * > by the JS API, the routes will be represented by a [GroupLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/GroupLayer/) * > rather than a [RouteLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/RouteLayer/). This does not affect copied route * > layer items after the ArcGIS Online 8.1 release or routes stored as portal items. * > Copying route layer items to be stored as part of the webmap is not a common scenario. * > * > Accessing geometries from popup features * > * Beginning with version 4.17, webmaps no longer return geometries in its popup's features. * > If a popup does not have a referenced Arcade expression that works with geometry, it is now * > required to set either the webmap layer's [FeatureLayer.outFields](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#outFields) * > or its PopupTemplate [PopupTemplate.outFields](https://developers.arcgis.com/javascript/latest/references/core/PopupTemplate/#outFields). * * @since 4.0 * @see [Sample - Load a basic WebMap](https://developers.arcgis.com/javascript/latest/sample-code/webmap-basic/) * @see [Sample - Load a basic WebMap and swap with another on the same View](https://developers.arcgis.com/javascript/latest/sample-code/webmap-swap/) * @see [UnknownLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/UnknownLayer/) * @see [UnsupportedLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/UnsupportedLayer/) */ export default class WebMap extends WebDocument2D { /** * Creates a new instance of this class and initializes it with values from a JSON object * generated from an ArcGIS product. The object passed into the input `json` * parameter often comes from a response to a query operation in the REST API or a * [toJSON()](https://pro.arcgis.com/en/pro-app/latest/tool-reference/conversion/features-to-json.htm) * method from another ArcGIS product. If the [WebMap](https://developers.arcgis.com/javascript/latest/references/core/WebMap/) is used outside of a view, you must call [load()](https://developers.arcgis.com/javascript/latest/references/core/WebMap/#load) * explicitly to interact with its resources. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/using-fromjson) * topic in the Guide for details and examples of when and how to use this function. * * @param json - A JSON representation of the instance in the ArcGIS format. See * the [web map specification](https://developers.arcgis.com/web-map-specification/) * for more detailed information on serializing web map to JSON. * @returns Returns a new instance of this class. * @since 4.12 * @example * // Retrieve a WebMap JSON by url and deserialize it into a WebMap API instance * const [esriRequest, WebMap] = await $arcgis.import(["@arcgis/core/request.js", "@arcgis/core/WebMap.js"]); * esriRequest("https://domain/url/to/webmap.json").then(function(json) { * const webmap = WebMap.fromJSON(json); * }); */ static fromJSON(json: any): WebMap; /** * @example * // Typical usage * const map = new WebMap({ * portalItem: { * id: "e691172598f04ea8881cd2a4adaa45ba" * } * }); * @example * // Typical usage * const map = new Map({ * basemap: "topo-vector" * }); */ constructor(properties?: WebMapProperties); /** * Information relating to a list of Geotriggers. * * @since 4.24 */ get geotriggersInfo(): GeotriggersInfo | null | undefined; set geotriggersInfo(value: GeotriggersInfoProperties | null | undefined); /** * Contains indoor positioning system information for the map. * * @since 4.31 */ get ipsInfo(): IPSInfo | null | undefined; set ipsInfo(value: IPSInfoProperties | null | undefined); /** Provides multiple slides. Each slide has a different "title", "extent", "basemap", "layers" etc. */ accessor presentation: any; /** * The version of the source document from which the WebMap was read. * The WebMap must be version 2.x to load into an app. * * @since 4.1 */ readonly sourceVersion?: Version | null; /** The utilityNetworks object contains a collection of [UtilityNetworks](https://developers.arcgis.com/javascript/latest/references/core/networks/UtilityNetwork/) saved on the web map. */ get utilityNetworks(): Collection<UtilityNetwork> | null | undefined; set utilityNetworks(value: ReadonlyArrayOrCollection<UtilityNetworkProperties> | null | undefined); }