aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarry Cutts <eternal.linux@gmail.com>2013-02-03 12:50:50 +0000
committerHarry Cutts <eternal.linux@gmail.com>2013-02-03 12:50:50 +0000
commit8f5a4db59286a083ecd9ab2ba20d0566783b0332 (patch)
tree344b071bab036ac407375520857dc25bd9b49f12
parent60b9618cef0fb622c5b994e9cc1e393972897900 (diff)
downloadhealth-map-8f5a4db59286a083ecd9ab2ba20d0566783b0332.tar
health-map-8f5a4db59286a083ecd9ab2ba20d0566783b0332.tar.gz
Put settlements into one layer, add to control
-rw-r--r--resources/map.js36
1 files changed, 16 insertions, 20 deletions
diff --git a/resources/map.js b/resources/map.js
index 9477114..ef1f63d 100644
--- a/resources/map.js
+++ b/resources/map.js
@@ -127,13 +127,13 @@ function displayMap(self, map) {
markers[feature.id] = layer;
},
filter: function(feature, layer) {
+ // TODO: Fix and make more efficient
return _.contains(_.values(feature.properties), amenity);
}
});
}
function createCatchmentAreaVillageLayer(catchmentArea) {
-
var poly = "";
_.each(catchmentArea.geometry.coordinates[0], function(coordinatePair) {
poly += coordinatePair[1] + " " + coordinatePair[0] + " ";
@@ -143,31 +143,14 @@ function displayMap(self, map) {
var query = 'data=[out:json];(node(poly:"' + poly + '");<;node(w););out;';
// Convert the data to GeoJSON
-
+ // TODO: Don't refetch villages on every map move
self.converter.fetch("http://overpass-api.de/api/interpreter", query, zoom, function(data) {
data.features = _.filter(data.features, function(feature) {
return _.contains(_.keys(feature.properties), "place") ||
feature.properties["landuse"] == "residential";
});
catchmentArea.populationAreas = data.features;
-
- if (typeof self.villageLayers[catchmentArea.id] == 'undefined') {
- self.villageLayers[catchmentArea.id] = L.geoJson(data, {
- style: function(feature) {
- return {fillColor: 'green',
- weight: 2,
- opacity: 1,
- color: 'black',
- dashArray: '3',
- fillOpacity: 0.1};
- }
- });
-
- map.addLayer(self.villageLayers[catchmentArea.id]);
- } else {
- self.villageLayers[catchmentArea.id].clearLayers();
- self.villageLayers[catchmentArea.id].addData(data);
- }
+ self.villageLayer.addData(data);
});
}
@@ -177,6 +160,19 @@ function displayMap(self, map) {
self.converter.fetch("http://overpass-api.de/api/interpreter", query, zoom, function(data) {
if (jQuery.isEmptyObject(self.amenityLayers)) {
+ self.villageLayer = L.geoJson(data, {
+ style: function(feature) {
+ return {fillColor: 'green',
+ weight: 2,
+ opacity: 1,
+ color: 'black',
+ dashArray: '3',
+ fillOpacity: 0.1};
+ }
+ });
+ map.addLayer(self.villageLayer);
+ self.layersControl.addOverlay(self.villageLayer, "Settlements");
+ self.villageLayer.clearLayers();
// For each catchment area polygon
_.each(
_.filter(data.features,