How to implement functionality similar to "saving file in .mxd format" in web application using arcgis api for javascript?

4210
12
07-15-2014 02:54 AM
GauriDeshmukh
New Contributor III

I need to implement a functionality which will save all layers added to map,its all display information like current extent, symbology and queried features if any etc. Its similar to saving an mxd(map document) file in arc map. But I want save this layer details in a table in database. When a user will open this saved file the layer should get added to map with all its saved properties. 

12 Replies
nicogis
MVP Frequent Contributor

You can have a similar functionality using the webmap format.

See this sample: Web map using JSON | ArcGIS API for JavaScript

Help format web map json: ArcGIS web map JSON format

GauriDeshmukh
New Contributor III

Hello Domenico Ciavarella

I am still not clear how to store the current json data or layer information of map.I want to save it but not getting how?

As per this sample I got the direction, it is about creating web map from json data.

0 Kudos
nicogis
MVP Frequent Contributor

Gauri Deshmukh‌, I don't think that there is an out of box for serialize in webmap. You can see sample project how this for serialize : swingley/cereal · GitHub

GauriDeshmukh
New Contributor III

ciava.at  excellent ..using the code for map-cereal.js from  swingley/cereal · GitHub‌, I am able to get JSON response for my current map document and can create Webmap from this json.

0 Kudos
GauriDeshmukh
New Contributor III

Now I am looking for converting this webmap to map or is there any way to construct a map again with the json response.

0 Kudos
KevinDeege
Esri Contributor

HI Gauri, this sample illustrates how to get a map from the web map response:

Web map using JSON | ArcGIS API for JavaScript

The key aspect of the sample is using the arcgisUtils class to create a deferred object, then obtain the map from the response.

arcgisUtils.createMap(webmap,"map").then(function(response){
     
var map = response.map;

//do something with the map here

GauriDeshmukh
New Contributor III

Hey KDeege-esristaff ,

I dont want to create web map  or a map like this, I want to add the layers which i got in response ,separately  to the map by map.addddLayer method (as per my requirement).

0 Kudos
GauriDeshmukh
New Contributor III

How do I add layer in the form of object to map.

0 Kudos
KevinDeege
Esri Contributor

Can you use the array of layers in the response as a way to accomplish this?

                var layers = response.itemInfo.itemData.operationalLayers;

0 Kudos