aboutsummaryrefslogtreecommitdiff
path: root/resources/map.js
diff options
context:
space:
mode:
Diffstat (limited to 'resources/map.js')
-rw-r--r--resources/map.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/resources/map.js b/resources/map.js
index cebadc7..e488a03 100644
--- a/resources/map.js
+++ b/resources/map.js
@@ -53,6 +53,12 @@ $(document).ready(function() {
$('.leaflet-control-layers-selector').first().trigger('click')
}
+ function createQueryURL(bbox) {
+ return "http://overpass-api.de/api/interpreter?" +
+ "data=[out:json];(node[amenity=hospital](" + bbox +
+ ");way[amenity=hospital]("+ bbox +");node(w););out;";
+ }
+
map.on('hospitalsfetched', addHospitalLayer);
map.on('locationfound', onLocationFound);
map.on('locationerror', onLocationError);
@@ -68,7 +74,7 @@ $(document).ready(function() {
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;";
+ var url = createQueryURL(bbox);
converter = new op2geojson();
converter.fetch(url, function(data) {
self.hospitals = data;
@@ -108,7 +114,7 @@ $(document).ready(function() {
}
function geojsonLayer() {
- url = "http://overpass-api.de/api/interpreter?data=[out:json];node[amenity=hospital](52.34,13.3,52.52,13.6);out;";
+ url = createQueryURL(52.34,13.3,52.52,13.6);
converter = new op2geojson();
converter.fetch(url, function(data) {
self.hospitals = data;