WebMap to json

6812
4
10-30-2015 11:09 AM
SebastienPelletier
Occasional Contributor

I use Web App Builder and I would like to know if there is a method to export the contents of a webmap to json. It is possible to open a webmap (json) like this :

https://developers.arcgis.com/javascript/jssamples/ags_createwebmapitem.html

but I have found nothing to export the webmap to json.

I tried the following method but it only records what is visible on the map.

var = Web_Map_as_JSON JSON.toJson (printTask._getPrintDefinition (this.map, params));

This method does not save everything in the toc and not visible on the map.

4 Replies
MichaelLacy
New Contributor III

As far as I know, there is nothing in v. 3.x of the JavaScript API to generate json for a web map, and it is not a trivial task to do it yourself.  It is supposed to be a feature of the 4.0 API, but as of Beta 1, it is not available yet.

Also, I suspect the PrintTask is generating an Export Web Map, which is slightly different.  According to Esri documentation on the ArcGIS web map format:

"The web map and its specification should not be confused with the ExportWebMap specification, which is used by ArcGIS Server when printing maps. Although you may notice similarities in properties, they are two different specifications."

Mike

DanielStauning
Esri Contributor

Sebastien,

You can try formatting the item id for your webmap in a request like this with f=pjson. If your map is shared with everyone this should work, otherwise, you'll need to embed a token in the request.

http://www.arcgis.com/sharing/content/items/YourWebMapID?f=pjson

Hope this helps,

-Dan

MichaelLacy
New Contributor III

Oh,that's true.  If your web map is already in ArcGIS Online or Portal for ArcGIS, you can export it in json format.  If you want to take a JavaScript map object and convert it to json (to be able to save it to AGOL or Portal), there is currently no way that I know of.

0 Kudos
SebastienPelletier
Occasional Contributor

Unfortunately this is not a solution because I added services which was not in the original webmap.

Also, the basemap widget lets you change the basemap (different from the one in online)

0 Kudos