passing map object between forms

797
12
11-03-2016 10:15 AM
BrianFoley1
New Contributor

Since I am having trouble creating a print template with it's associated legend, I decided to play around with creating my

own form that mimics how I want the template to look.  I have my main form which displays the map and let's the user pick which layers are visible.  They can then choose to print that map.  I then want to send them to my print form which will format the map/legend slightly differently that the display form.  I was wondering if it's possible to pass the map object between the two forms. 

If this is not possible, then I'll get back to creating a print template.  btw, I was successful in creating a print service using the tutorial that RS sent me. 

0 Kudos
12 Replies
AndrewTimmins
Regular Contributor

You will want to 'put' the map into storage. But I believe it has to be in JSON form.

storageProvider.put("myValue", myObject, function(status, keyName){
            alert("value put in "+keyName);
    });

0 Kudos
BrianFoley1
New Contributor

I tried the code from the first link to sent 'Export Map as JSON' :

   var printTask = new esri.tasks.PrintTask();

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

but get the following error:

JavaScript runtime error: Object doesn't support property or method 'toJson'

0 Kudos
AndrewTimmins
Regular Contributor

it looks like the function has changed a little.

Its more like

var webmap = printTask._getPrintDefinition(map, printparams)

Get the WebMap from Javascript API esri/map 

0 Kudos