aboutsummaryrefslogtreecommitdiff
path: root/resources
diff options
context:
space:
mode:
Diffstat (limited to 'resources')
-rw-r--r--resources/map.js19
-rw-r--r--resources/op2geojson.js9
2 files changed, 16 insertions, 12 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;
diff --git a/resources/op2geojson.js b/resources/op2geojson.js
index 55be9e3..c453df7 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 = [];
@@ -19,7 +19,8 @@ op2geojson = function() {
// Add nodes and ways to the layer
var features = [];
$.each(data.elements, function(i, item) {
- if( item.type === 'node' && item.tags != null ) {
+ if( item.type === 'node' && item.tags != undefined
+ && item.tags['amenity'] != undefined) {
features.push( instance.point(item) );
} else if (item.type === 'way') {
features.push( instance.lineString(item, nodes) );
@@ -28,7 +29,7 @@ op2geojson = function() {
geojson = instance.featureCollection(features);
callback(geojson);
}
- );
+ , "json");;
};
instance.point = function(node) {