aboutsummaryrefslogtreecommitdiff
path: root/resources/op2geojson.js
diff options
context:
space:
mode:
authorChristopher Baines <cbaines8@gmail.com>2012-12-09 18:01:58 +0000
committerChristopher Baines <cbaines8@gmail.com>2012-12-09 18:01:58 +0000
commit56e4328f9b1f1fe949403fc7f2d38cd32c7d83cc (patch)
treebd0b9db146a35461798b39eabcca385a3ea2b3ea /resources/op2geojson.js
parentc3a7e1eb5808d8c2a0df134f77214892c1cdefef (diff)
downloadhealth-map-56e4328f9b1f1fe949403fc7f2d38cd32c7d83cc.tar
health-map-56e4328f9b1f1fe949403fc7f2d38cd32c7d83cc.tar.gz
Fix key, and display nodes instead of ways for hospitals when zoomed out
Diffstat (limited to 'resources/op2geojson.js')
-rw-r--r--resources/op2geojson.js18
1 files changed, 16 insertions, 2 deletions
diff --git a/resources/op2geojson.js b/resources/op2geojson.js
index 5a979b1..3221842 100644
--- a/resources/op2geojson.js
+++ b/resources/op2geojson.js
@@ -5,7 +5,7 @@ op2geojson = function() {
var instance = {},
geojson;
- instance.fetch = function(url, data, callback) {
+ instance.fetch = function(url, data, zoom, callback) {
$.post(url, data,
function(data) {
// Add nodes and ways to the layer
@@ -35,7 +35,21 @@ op2geojson = function() {
});
$.each(ways, function(i, way) {
- features.push( instance.lineString(way, nodes) );
+ if (zoom < 16) {
+ var node = nodes[way.nodes[0]];
+ var point = {
+ "type" : "Feature",
+ "geometry" : {
+ "type" : "Point",
+ "coordinates" : [node.lon,node.lat]
+ },
+ "properties" : {}
+ };
+ _.extend(point.properties, way.tags);
+ features.push( point );
+ } else {
+ features.push( instance.lineString(way, nodes) );
+ }
});
$.each(relations, function(i, relation) {