From 05d950cbc090cac472276035082cb337b6a30642 Mon Sep 17 00:00:00 2001 From: Willi Date: Sat, 1 Dec 2012 19:31:27 +0100 Subject: updating hospital pins on panning --- resources/map.js | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'resources') diff --git a/resources/map.js b/resources/map.js index d98cc87..cb0f0e4 100644 --- a/resources/map.js +++ b/resources/map.js @@ -20,21 +20,34 @@ $(document).ready(function() { map.on('locationfound', onLocationFound); map.on('locationerror', onLocationError); + map.on('moveend', function(e) { + if (!self.hospitalLayer) + return; + var bounds = map.getBounds(); + var sw = bounds.getSouthWest(); + var ne = bounds.getNorthEast(); + bbox = [sw.lat, sw.lng, ne.lat, ne.lng].join(','); + var url = "http://overpass-api.de/api/interpreter?data=[out:json];node[amenity=hospital](" + bbox + ");out;"; + converter = new op2geojson(); + converter.fetch(url, function(data) { + layer = L.geoJson(data, { + onEachFeature: function(feature, layer) { + layer.bindPopup(feature.properties.name); + } + }); + self.hospitalLayer.addData(data); + }); + + + }) + map.locate({setView: true, maxZoom: 12}); function geojsonLayer() { url = "http://overpass-api.de/api/interpreter?data=[out:json];node[amenity=hospital](52.34,13.3,52.52,13.6);out;"; converter = new op2geojson(); converter.fetch(url, function(data) { - var style = { - "color": "red", - "weight" : 50, - "opacity" : 0.65 - }; layer = L.geoJson(data, { - style: function(feature) { - return style; - }, onEachFeature: function(feature, layer) { layer.bindPopup(feature.properties.name); } -- cgit v1.2.3