2010-07-30 22:25:21 +00:00
|
|
|
<!doctype html>
|
|
|
|
<html>
|
|
|
|
<head>
|
2010-08-14 18:52:01 +00:00
|
|
|
<title>js-shapefile-to-geojson Demo Page</title>
|
2010-07-30 22:25:21 +00:00
|
|
|
<style>
|
2010-08-14 18:52:01 +00:00
|
|
|
html, body {
|
2010-07-30 22:25:21 +00:00
|
|
|
height: 100%;
|
|
|
|
width: 100%;
|
|
|
|
}
|
2010-08-14 18:52:01 +00:00
|
|
|
#map {
|
|
|
|
height: 400px;
|
|
|
|
background-color: #eee;
|
|
|
|
}
|
2010-07-30 22:25:21 +00:00
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
2011-05-04 17:21:54 +00:00
|
|
|
<a href="http://github.com/wavded/js-shapefile-to-geojson"><img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" /></a>
|
2010-08-14 18:52:01 +00:00
|
|
|
<h2>js-shapefile-to-geojson Demo Page</h2>
|
|
|
|
<p>Pure client-side JavaScript (no server side code) parsing of shapefiles and dbase files to GeoJSON format displayed using OpenLayers.</p>
|
|
|
|
<div id="map"></div>
|
|
|
|
<p>View project at <a href="http://github.com/wavded/js-shapefile-to-geojson">http://github.com/wavded/js-shapefile-to-geojson</a>.
|
2010-08-14 18:20:00 +00:00
|
|
|
<script src="http://rs1.adc4gis.com/js/openlayers/2.9.1/OpenLayers-Proj4.js"></script>
|
2010-07-30 22:25:21 +00:00
|
|
|
<script src="stream.js"></script>
|
|
|
|
<script src="shapefile.js"></script>
|
|
|
|
<script src="dbf.js"></script>
|
|
|
|
<script type="text/javascript">
|
2010-08-14 18:20:00 +00:00
|
|
|
OpenLayers._getScriptLocation = function(){
|
|
|
|
return "http://rs1.adc4gis.com/js/openlayers/2.9.1/";
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-07-30 22:25:21 +00:00
|
|
|
var starttime = +new Date,
|
2010-08-14 18:20:00 +00:00
|
|
|
map = new OpenLayers.Map("map",{allOverlays: true}),
|
|
|
|
parser = new OpenLayers.Format.GeoJSON(),
|
|
|
|
vector = new OpenLayers.Layer.Vector("Converted"),
|
|
|
|
|
2010-07-30 22:25:21 +00:00
|
|
|
shapefile = new Shapefile({
|
2013-03-29 11:39:00 +00:00
|
|
|
shp: "sld_cookbook_line.shp",
|
|
|
|
dbf: "sld_cookbook_line.dbf"
|
2010-07-30 22:25:21 +00:00
|
|
|
}, function(data){
|
2010-08-14 18:20:00 +00:00
|
|
|
var features = parser.read(data.geojson);
|
|
|
|
vector.addFeatures(features);
|
|
|
|
map.zoomToExtent(vector.getDataExtent());
|
|
|
|
|
2010-07-30 22:25:21 +00:00
|
|
|
console.log("took",new Date - starttime,"milliseconds")
|
|
|
|
console.log(data);
|
|
|
|
})
|
2010-08-14 18:20:00 +00:00
|
|
|
|
|
|
|
map.addLayer(vector);
|
2010-07-30 22:25:21 +00:00
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|