Save my drawings as a layer

3506
5
05-19-2015 11:32 AM
deleted-user-yA_w_FC9FKe5
New Contributor III

I’ve been challenged to create a project that allows a user to markup a map.  They want to be able to do the following:

  1. Add text to the map.
  2. Add a polygon with the option to show the area of that polygon.
  3. Add Points to the map
  4. Save the document with these added text, polygons and points.
  5. Print the document as a pdf with these graphics. 

I was using the advanced drawing tool (link below) and modified it to do what I want but then they threw the whole curve ball of wanting to save the changes.  Can you save your graphics to a layer?  If so how would I do that?

I would like to do that if possible using a button like below. 

<button data-dojo-type="dijit/form/Button" disabled="true">Save</button>

Advanced Drawing toolbar link. If you haven’t seen it you should. It is very nicely done. 

https://community.esri.com/people/timw1984/blog/2014/07/22/javascript-api-advanced-draw-widget

Reply
0 Kudos
5 Replies
TimWitt2
MVP Regular Contributor

Maybe this thread can help? Convert a graphicsLayer to JSON

ChrisSmith7
Frequent Contributor

I like this solution. We have mapping app that exposes annotation tools - although we do not allow users to save, it's something on our radar.

Michael,

I'm not sure of your platform, but if you happen to be using asp.net, and are hosting the map within an .aspx, you can easily call page/web methods from the map to execute server side logic, such as saving the JSON layer to SQL Server by a user id, or session id, and then later re-load it/make available when the user revisits. If this is helpful for you, I can give more information, otherwise, Tim's link mentions some info on dojo.xhr.

Reply
0 Kudos
SteveCole
Frequent Contributor

Depending on what your definition of "save" is, you might also be able to work with HTML5's local Storage. I'm using this technique in one of my applications. Here's a forum post that has the technique I borrowed. If you're forced to use IE (and especially an older version of IE), this technique may not work well for you since IE isn't as HTML5 compliant as Chrome or Firefox.

The other thing to note is that clearing the browser's cache/history would likely delete any "saved" work. That's why I referenced what your definition of save might be. This might work well for "in the moment" type work but not so much if you want to open it months later. Also, I'm using this technique to store graphic shapes, not text. I don't know how that might (or might not) work.

Steve

deleted-user-yA_w_FC9FKe5
New Contributor III

I don't think local drive is the answer I am looking for.  I want the user to be able to add some graphics to the map and be able to save them so that when they come back to this map they see the graphics they added. 

Reply
0 Kudos
deleted-user-Pi5x1UjkS2PY
New Contributor II

Thought I should expand on this.  I think it would be best to save these graphics serverside and if possible with a unique name so that the users can have multiple sets of edits.  I want to be able to give them a drop down box so that they can bring in different versions of the grapic's for the same map. 

I hope that makes some sense.

Reply
0 Kudos