passing map object between forms

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

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
RobertScheitlin__GISP
MVP Emeritus

Brain,

  I don't see why not just have a global var on the second form and set the map to it from the first form.

0 Kudos
BrianFoley1
New Contributor II

How would I do that using JavaScript ?

Sent from my iPhone

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Brain,

   It would be hard fro me to provide any code as I really am not confident on your workflow and would have to write a lot of code from scratch to demo this.

0 Kudos
BrianFoley1
New Contributor II

No worries Robert

Sent from my iPhone

0 Kudos
BrianFoley1
New Contributor II

No worries Robert

Sent from my iPhone

0 Kudos
Drew
by
Occasional Contributor III

You could look at converting the map to JSON using the Print task
arcgis javascript api - export map state as JSON: Web_Map_as_JSON  

Then store the JSON in the browsers storage to be later retrieved on the next page.

Drew

BrianFoley1
New Contributor II

Thanks Andrew, I'll have to take a look at that when I get back to the office Monday

0 Kudos
Drew
by
Occasional Contributor III

Or depending on what you are doing exactly, you could just export the map image from the REST or from a MAP_ONLY Print and then pass the generate URL to the next form.

0 Kudos
BrianFoley1
New Contributor II

Andrew,

 

        In the following example from the dojox.storage link you provided, where would the actual map object go ?

dojo.require("dojox.storage");
var storageProvider=null;
dojo.addOnLoad(function(){
    dojox.storage.manager.initialize();
    storageProvider=dojox.storage.manager.getProvider();
    storageProvider.initialize();
    var myObject={key1:true};
    storageProvider.put("myValue", myObject, function(status, keyName){
            alert("value put in "+keyName);
    });
});

0 Kudos