I'm using the advanced draw tools (modified to fit my needs) that Tim Witt has created (Javascript API - Advanced Draw widget )
What I would like to be able to do is allow a user to save his/her changes to a file so that when they can come back in a latter session they can load any markups that they did before.
I found a way to load the files back in if I can zip them all into one file using this (Add shapefile | ArcGIS API for JavaScript ).
However, I've been desperately trying to find a way to create a zip file so that I can save a users drawings. I ran into this code and downloaded it as it sounds like it will do exactly what I want. I can't get it to work though.
I want to use this in a function for a save button.
I added this at the top:
<script src='shp-write-master/bundle.js'></script>
I then tried adding in the require statement in the function as you see below but then also at the top where I require everything else as well but my code does not get past my second alert box. Has anyone used this before and have a simple example of how they called it or know what I am doing wrong here?
function fnSave() {
alert("Still a work in progress");
var shpwrite = require('shp-write');
alert("Made it middle");
// (optional) set names for feature types and zipped folder
var options = {
folder: 'myshapes',
//folder: 'L:\Javascript_Mobile\CAD2GIS\myshapes',
types: {
point: 'mypoints',
polygon: 'mypolygons',
line: 'mylines'
}
}
alert("Made it middle");
// a GeoJSON bridge for features
shpwrite.download({
type: 'FeatureCollection',
features: [
{
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [0, 0]
},
properties: {
name: 'Foo'
}
},
{
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [0, 10]
},
properties: {
name: 'Bar'
}
}
]
}, options);
alert("Made it end");
};
If you get this working, can you post the code here? I am very interested in being able to work in Advanced Draw with a simple save button.
Yes, this is a bit over my head. I, like Michael, would love to have something that Advanced Draw tool with a "Save to shapefile" button.