aboutsummaryrefslogtreecommitdiff
path: root/resources
diff options
context:
space:
mode:
authorWilli <willi@jups42.de>2012-12-01 19:31:27 +0100
committerWilli <willi@jups42.de>2012-12-01 19:31:27 +0100
commit05d950cbc090cac472276035082cb337b6a30642 (patch)
treed77f4c979cf0dc2e84dc10f11c587e73ad1a24bb /resources
parent03234d0192da6c1c4744e05b12f34c8bcbf051b6 (diff)
downloadhealth-map-05d950cbc090cac472276035082cb337b6a30642.tar
health-map-05d950cbc090cac472276035082cb337b6a30642.tar.gz
updating hospital pins on panning
Diffstat (limited to 'resources')
-rw-r--r--resources/map.js29
1 files changed, 21 insertions, 8 deletions
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);
}