-
Notifications
You must be signed in to change notification settings - Fork 196
Open
Description
First: thanks for your excellent work!
I'm a HTML+JS noobie, and it would have helped me a lot to see a complete, minimal example, with just HTML+JS:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Shapefile Export</title>
<!-- Import FileSaver.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.5/FileSaver.min.js"></script>
<!-- Import shp-write.js -->
<script src="https://unpkg.com/@mapbox/shp-write@latest/shpwrite.js"></script>
</head>
<body>
<button onclick="exportShapefile()">Export Shapefile</button>
<script>
function exportShapefile() {
// Sample data
var data = {
type: 'FeatureCollection',
features: [{
type: 'Feature',
properties: {
name: 'Some polygon'
},
geometry: {
type: 'Polygon',
coordinates: [[
[-64.8, 32.3], [-65.5, 18.3], [-80.3, 25.2], [-64.8, 32.3]]]
}
}]
};
// Save the zip file
shpwrite.zip(data, { outputType: "blob" }).then(function (zipBlob) {
saveAs(zipBlob, "my_shapefile.zip");
});
}
</script>
</body>
</html>It can be run here: https://jsfiddle.net/pd14t8ew/2/
It's really not very different from the existing doc, but it took me a while to find the correct inputs.
If you're interested, I could write a corresponding PR for documentation.
Caydence45 and charlieforward9
Metadata
Metadata
Assignees
Labels
No labels