aboutsummaryrefslogtreecommitdiff
path: root/resources
diff options
context:
space:
mode:
Diffstat (limited to 'resources')
-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,