diff options
author | Willi Müller <willi.mueller@jups42.de> | 2012-12-02 06:29:11 -0800 |
---|---|---|
committer | Willi Müller <willi.mueller@jups42.de> | 2012-12-02 06:29:11 -0800 |
commit | 656847f983b84387229f6010fd000d0348566fa2 (patch) | |
tree | adf6d39ef4d8a3a3b4075e2118d9242e6812f3f6 /resources/map.js | |
parent | f275c96c3784202e64c4ca666e434d368175e868 (diff) | |
parent | e010ed88f47e5e1629aaa494ccb8c173299842b0 (diff) | |
download | health-map-656847f983b84387229f6010fd000d0348566fa2.tar health-map-656847f983b84387229f6010fd000d0348566fa2.tar.gz |
Merge pull request #4 from Fodaro/master
Convert to POST, and add doctors and dentists
Diffstat (limited to 'resources/map.js')
-rw-r--r-- | resources/map.js | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/resources/map.js b/resources/map.js index 6d00c2e..4c8c9cd 100644 --- a/resources/map.js +++ b/resources/map.js @@ -56,10 +56,13 @@ $(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;"; + function createQueryData(bbox) { + // TODO: Use POST instead of GET, for neatness + return "data=[out:json];(" + + "(node[amenity=hospital]("+ bbox +");way[amenity=hospital]("+ bbox +");node(w););" + + "(node[amenity=doctors]("+ bbox +");way[amenity=doctors]("+ bbox +");node(w););" + + "(node[amenity=dentist]("+ bbox +");way[amenity=dentist]("+ bbox +");node(w););" + + ");out;"; } map.on('hospitalsfetched', addHospitalLayer); @@ -77,9 +80,9 @@ $(document).ready(function() { var sw = bounds.getSouthWest(); var ne = bounds.getNorthEast(); bbox = [sw.lat, sw.lng, ne.lat, ne.lng].join(','); - var url = createQueryURL(bbox); + var data = createQueryData(bbox); converter = new op2geojson(); - converter.fetch(url, function(data) { + converter.fetch("http://overpass-api.de/api/interpreter", data, function(data) { self.hospitals = data; layer = buildLayer(data) self.hospitalLayer.addData(data); @@ -127,9 +130,9 @@ $(document).ready(function() { } function geojsonLayer() { - url = createQueryURL(52.34,13.3,52.52,13.6); + data = createQueryData([52.34,13.3,52.52,13.6]); converter = new op2geojson(); - converter.fetch(url, function(data) { + converter.fetch("http://overpass-api.de/api/interpreter", data, function(data) { self.hospitals = data; layer = buildLayer(data); self.hospitalLayer = layer; |