diff options
author | Katie Filbert <filbertk@gmail.com> | 2012-12-01 16:20:21 +0100 |
---|---|---|
committer | Katie Filbert <filbertk@gmail.com> | 2012-12-01 16:20:21 +0100 |
commit | 052bb51e2b1a0bdd038a51b1c19849c6b959d3e5 (patch) | |
tree | 8c321584e809b4ace481eeb471161411f9f75290 /resources | |
parent | 41b0fe477b6533acf605f4ba35604a81dc2c5ae3 (diff) | |
download | health-map-052bb51e2b1a0bdd038a51b1c19849c6b959d3e5.tar health-map-052bb51e2b1a0bdd038a51b1c19849c6b959d3e5.tar.gz |
adding geojson layer
Diffstat (limited to 'resources')
-rw-r--r-- | resources/map.js | 8 | ||||
-rw-r--r-- | resources/op2geojson.js | 50 |
2 files changed, 56 insertions, 2 deletions
diff --git a/resources/map.js b/resources/map.js index 9c466ae..20b5a84 100644 --- a/resources/map.js +++ b/resources/map.js @@ -12,10 +12,14 @@ $(document).ready(function() { map.locate({setView: true, maxZoom: 16}); - initLayerControl(); + function geojsonLayer() { + converter = new op2geojson(); + data = converter.geojson(); + return L.geoJson(data); + } function fetchLayers() { - self.hospitalLayer = L.tileLayer("http://overpass-api.de/api/interpreter?data=[out:json];node[amenity=hospital](52.34,13.3,52.52,13.6);out;"); + self.hospitalLayer = geojsonLayer(); self.tileLayer = L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom: 18, attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors' diff --git a/resources/op2geojson.js b/resources/op2geojson.js new file mode 100644 index 0000000..42aa341 --- /dev/null +++ b/resources/op2geojson.js @@ -0,0 +1,50 @@ +( function ( $ ) { + +op2geojson = function() { + + var instance = {}, + geojson; + + instance.fetch = function(url) { + $.getJSON("http://overpass-api.de/api/interpreter?data=[out:json];node[amenity=hospital](52.34,13.3,52.52,13.6);out;", { + format: "json" + }, + function(data) { + $.each(data, function(i, item) { + console.log(item); + }); + } + ); + }; + + instance.feature = function() { + point = { + "geometry" : { + "type" : "Point", + "coordinates" : [52.43,13.45] + }, + "type" : "Feature", + "properties" : { "prop0" : "value0" }, + }; + return point; + } + + instance.featureCollection = function() { + collection = { + "type" : "FeatureCollection", + "features" : [ + instance.feature(), + ] + }; + return collection; + } + + instance.geojson = function() { + return instance.featureCollection(); + } + + return instance; + +}; + +})( jQuery ); |