-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.html
71 lines (53 loc) · 2.24 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<!-- Drag and drop based from @remy's HTML5 demos: https://github.com/remy/html5demos -->
<title>shapefile-to-webmap</title>
<style>
#holder { border: 10px dashed gray; width: 300px; height: 300px; margin: 20px auto;}
#holder.hover { border: 10px dashed #333; }
body { background-color: #99CCFF; font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; }
#text { width: 300px; height: 300px; margin: auto; }
#footer { position: absolute; right: 35px; bottom: 15px; width: 100px; height: 50px; text-align: right; }
</style>
<body>
<article>
<div id="holder"></div>
<div id="text">
<p id="status">Sorry! Your web browser isn't supported. Try downloading the (free and awesome) <a href="http://www.google.com/chrome">Google Chrome</a> browser.</p>
<p>Drag a shapefile (.zip) from your desktop into the box above to generate a web map!</p>
</div>
<div id="footer">built by<br>Dave Guarino<br><a href="https://twitter.com/allafarce">@allafarce</a></div>
</article>
<a href="https://github.com/daguar/shapefile-to-webmap"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub"></a>
</body>
<script src="js/shp.min.js"></script>
<script>
var holder = document.getElementById('holder'),
state = document.getElementById('status');
var error, geojson;
if (typeof window.FileReader === 'undefined') {
state.className = 'fail';
} else {
state.className = 'success';
state.innerHTML = '';
}
holder.ondragover = function () { this.className = 'hover'; return false; };
holder.ondragend = function () { this.className = ''; return false; };
// Main workhorse: on file drop
holder.ondrop = function (e) {
this.className = '';
e.preventDefault();
var file = e.dataTransfer.files[0],
reader = new FileReader();
// On success, forward the data on to GeoJson.io
function forwardToGeoJsonIo(data) {
geojson = data;
url = "http://geojson.io/#data=data:application/json," + encodeURIComponent(JSON.stringify(data));
window.location = url;
console.log(data);
}
reader.onload = function (event) {
shp(this.result).then(forwardToGeoJsonIo);
};
reader.readAsArrayBuffer(file);
return false;
};
</script>