This sample demonstrates how to save a WebMap to a Portal for ArcGIS item by creating a new item. Saving a web map is easy. All that's required is a WebMap and a valid Portal to save the map to.
Saving to a new itemCreate a new empty WebMap instance or load an existing web map in your application. To save an existing webmap as a new portal item call saveAs() method. This saves the web map to a new portal item. Saving will trigger user authentication, and if successful the item will be saved to the given Portal.
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/************************************************************
* Creates a new WebMap instance. A WebMap can reference
* a PortalItem ID that represents a WebMap saved to
* arcgis.com or an on-premise portal.
************************************************************/
const webmap = new WebMap({
portalItem: {
id: "06ca49d0ddb447e7817cfc343ca30df9"
},
});
// Update properties of the WebMap related to the view.
// This should be called just before saving a webmap.
webmap.updateFrom(viewElement.view).then(() => {
webmap.saveAs(item).then((item) => {
console.log("WebMap saved successfully");
})
// Save didn't work correctly
.catch((error) => {
console.error("Webmap did not save.")
});
});
Please refer to the ArcGIS Organization portals for information on how the ArcGIS Maps SDK for JavaScript makes use of working with portal items.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4