Draw Widget - How to save drawing

2979
2
12-13-2017 03:59 AM
MARTINWILSON1
New Contributor

Hi Guys

I have added the draw widget to my map.  The drawing functions work fine on the published app, but there is no way to save the drawing.  How do I do this?  I want to be able to send a link to someone of the map, and for them to mark on an area, save that area, and for me to open the map and see that area.

Thanks

2 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Martin,

   You should look at the Enhanced Draw custom widget then:

GitHub - magis-nc/esri-webappbuilder-widget-eDraw: Ehanced draw widget for WebApp Builder for Arcgis... 

Demo site:

ArcGIS Web Application 

GeoguichetGeoguichet
New Contributor III

Hello.

I dit not use eDraw, because I don't really like it/don't want this layers structure.
I'ts probably similar, but I did as follows in the standard Draw Widget, in order to save and load a drawing (to/from file):

var graphics = this._getAllGraphics();

var jsonString = "[";
array.forEach(graphics, lang.hitch(this, function(g){
   jsonString = jsonString + "{\"geotype\":\"" + g.geometry.geoType + "\",\"graphic\":" + jsonRef.toJson(g.toJson()) + "},";
}));
jsonString = jsonString.substring(0, jsonString.length - 1) + "]";

var filename = "Drawing.json";
return CSVUtils._download(filename, jsonString);

jsonRef refers to 'dojox/json/ref' and CSVUtils to 'jimu/CSVUtils'

And to import a JSON string/file:

var objects = jsonRef.fromJson(evt.target.result);
for(var i = 0; i < objects.length; i++) {
   var parsedGraphic = new Graphic(objects.graphic);
   var geoType = objects.geotype;

   this._onDrawEnd(parsedGraphic, geoType, null);
}

evt.target.result comes for a Reader object (onload event)

0 Kudos