aboutsummaryrefslogtreecommitdiff
path: root/resources
diff options
context:
space:
mode:
authorChristopher Baines <cbaines8@gmail.com>2013-02-15 20:26:14 +0000
committerChristopher Baines <cbaines8@gmail.com>2013-02-15 20:26:14 +0000
commitdb408996fa441654c6aaa5688706b2b10fd3b04a (patch)
treed3d5d32beb97af8560535d424cd054e7355c7ef6 /resources
parent70ce303fc99cfaffa25141024c69c602ef89ede0 (diff)
downloadhealth-map-db408996fa441654c6aaa5688706b2b10fd3b04a.tar
health-map-db408996fa441654c6aaa5688706b2b10fd3b04a.tar.gz
Add a population heat map
Diffstat (limited to 'resources')
m---------resources/heatmap0
-rw-r--r--resources/map.js24
2 files changed, 23 insertions, 1 deletions
diff --git a/resources/heatmap b/resources/heatmap
new file mode 160000
+Subproject e69a5bbedfd9718ebe0ac2bf161a28503c1285e
diff --git a/resources/map.js b/resources/map.js
index 64484f3..8a006bc 100644
--- a/resources/map.js
+++ b/resources/map.js
@@ -172,6 +172,21 @@ function initMap(self) {
map.addLayer(self.settlementsLayerGroup);
self.layersControl.addOverlay(self.settlementsLayerGroup, "Settlements");
+ self.populationHeatMap = new L.TileLayer.heatMap({
+ radius: 20,
+ opacity: 0.8,
+ gradient: {
+ 0.45: "rgb(0,0,255)",
+ 0.55: "rgb(0,255,255)",
+ 0.65: "rgb(0,255,0)",
+ 0.95: "yellow",
+ 1.0: "rgb(255,0,0)"
+ }
+ });
+
+ map.addLayer(self.populationHeatMap);
+ self.layersControl.addOverlay(self.populationHeatMap, "Population Heat Map");
+
var emptyFeatureCollection = { type: "FeatureCollection", features: [] };
var hospitalIcon = L.icon({
@@ -360,14 +375,20 @@ function displayMap(self, map) {
var displayProperties = { name: feature.properties["name"], population: feature.properties["population"] };
if (typeof displayProperties["name"] == "undefined")
displayProperties["name"] = "Unknown";
- if (typeof displayProperties["population"] == "undefined")
+ if (typeof displayProperties["population"] == "undefined") {
displayProperties["population"] = "Unknown";
+ } else {
+ self.populationHeatMapData.push({lat: center[1], lon: center[0], value: feature.properties.population});
+ }
layer.bindPopup(self.editorTemplate({coordinate: center}) + self.settlementTemplate(displayProperties));
}
});
self.settlementsLayerGroup.addLayer(self.catchmentAreaSettlementsLayers[catchmentArea.id]);
+ self.populationHeatMap.addData(self.populationHeatMapData);
+ self.populationHeatMap.redraw();
+
var healthPost = self.healthPosts[catchmentArea.properties.subject];
var center;
@@ -393,6 +414,7 @@ function displayMap(self, map) {
_.each(self.amenitiesShown, function(amenity) {
self.amenities[amenity] = [];
});
+ self.populationHeatMapData = [];
// Convert the data to GeoJSON
self.converter.fetch("http://overpass-api.de/api/interpreter", query, zoom, function(data) {