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:
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.
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.
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.
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.
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.
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.