diff options
author | Christopher Baines <cbaines8@gmail.com> | 2013-02-03 12:55:26 +0000 |
---|---|---|
committer | Christopher Baines <cbaines8@gmail.com> | 2013-02-03 12:55:26 +0000 |
commit | abc87bf4e219dff3b89219423e2aa6873e0c1844 (patch) | |
tree | 1302960e9083d94472978307526f985881689bf3 | |
parent | 5bb80ec2e357b396548bfd61529f957677c44016 (diff) | |
parent | 8f5a4db59286a083ecd9ab2ba20d0566783b0332 (diff) | |
download | health-map-abc87bf4e219dff3b89219423e2aa6873e0c1844.tar health-map-abc87bf4e219dff3b89219423e2aa6873e0c1844.tar.gz |
Merge remote-tracking branch 'fodaro/master'
Conflicts:
resources/map.js
-rw-r--r-- | resources/map.js | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/resources/map.js b/resources/map.js index a7c26d0..b51e456 100644 --- a/resources/map.js +++ b/resources/map.js @@ -145,13 +145,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] + " "; @@ -161,31 +161,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.settlements = 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); }); } @@ -195,6 +178,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, |