Is there an example where the user simply draws a polygon and then can save/export to a named shapefile?
I believe I found something. The code sample from the broken links in js2shapefile is available in this GitHub:GitHub - borisdev/js2shapefile: Automatically exported from code.google.com/p/js2shapefile.
I forked the repo, downloaded, and this sample actually works: js2shapefile/Test_EsriDrawToShapefile.html at master · borisdev/js2shapefile · GitHub . Uses Draw Toolbar to create lines, points, and polygons and can save all at once into their shapefiles. Pretty cool!
After downloading the shapefile(s), you just need to assign them the Web Mercator Auxiliary Sphere projection. Once you have that .prj file, you can copy and rename to match others. Tool just creates .dbf, .shp, .shx files.
Code is 4 years old and uses ArcGIS JS 2.6, but is a simple app and a good starting point to upgrade to 3.16 and rework/modify the GUI. Would be good to be able to name shapefiles you save. Also needs to "Clear Graphics" button, only way to draw and export additional shapefiles is to refresh page.
There are couple of opinions out there. Take a look at below links
Using shp-write to export as shapefile
If it is just for persistence and not to use it elsewhere, I would suggest you to just save it as json file.
OK, I found all those you list previously.
The example links in the JS2Shapefile page just give me 404 page errors, which is really too bad, since these look good. Would really love to see "modification of the Draw Toolbar sample to let you save the results to a shapefile."
The other links you list above I checked out but I didn't get very far. All looks a bit confusing and did not see exactly where one can save data after drawing.
I LOVE the Advanced Draw tool. Just needs a Save to Shapefile button and I'd be golden. Seems like somebody out there must have done this.
I assume you want to do this client-side? Otherwise you could create your own server side GP service that does it for you by sending the geometries as ArcGIS JSON to the GP service and using the ArcPy tools in your GP model/script to do the convert to feature class and zip it up in a single file. That way you can "convert to shp" over and over and ensure that the data returned has projection information. You can also do all kind of other stuff with it in the GP service e.g. add additional fields, calculate geometry properties, convert to other additional formats etc.
Thanks so much for your response and advice. Much appreciated. I was just seeing what was out there in terms of what other people have done. Yes, a GP service would be great and I eventually may do this ( I have coworkers who have done this already). I also happened to find an older client-side example ( see my above message with links to js2Shapefile code). Have never created a GP service before but looks like this would be a good case to learn and start. But other client-side examples would be great to see as well.
Retrieving data ...