aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarry Cutts <eternal.linux@gmail.com>2012-12-02 13:50:10 +0000
committerChristopher Baines <cbaines8@gmail.com>2012-12-02 14:32:23 +0000
commita1fce06c1857c99d8a421f513180d299617edacb (patch)
treea2a8c88e1afb7ed5a5702566fad75980a4be38b0
parentba250309eb98e5956ca532b4823181745c9a9a55 (diff)
downloadhealth-map-a1fce06c1857c99d8a421f513180d299617edacb.tar
health-map-a1fce06c1857c99d8a421f513180d299617edacb.tar.gz
Change from using GET to POST, for neatness
-rw-r--r--resources/map.js17
-rw-r--r--resources/op2geojson.js6
2 files changed, 12 insertions, 11 deletions
diff --git a/resources/map.js b/resources/map.js
index 6d00c2e..077e370 100644
--- a/resources/map.js
+++ b/resources/map.js
@@ -56,10 +56,11 @@ $(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););out;";
}
map.on('hospitalsfetched', addHospitalLayer);
@@ -77,9 +78,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 +128,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;
diff --git a/resources/op2geojson.js b/resources/op2geojson.js
index 55be9e3..0fa2967 100644
--- a/resources/op2geojson.js
+++ b/resources/op2geojson.js
@@ -5,8 +5,8 @@ op2geojson = function() {
var instance = {},
geojson;
- instance.fetch = function(url, callback) {
- $.getJSON(url, { format: "json" },
+ instance.fetch = function(url, data, callback) {
+ $.post(url, data,
function(data) {
// List all of the returned nodes
var nodes = [];
@@ -28,7 +28,7 @@ op2geojson = function() {
geojson = instance.featureCollection(features);
callback(geojson);
}
- );
+ , "json");;
};
instance.point = function(node) {