diff options
Diffstat (limited to 'resources')
m--------- | resources/heatmap | 0 | ||||
-rw-r--r-- | resources/map.js | 24 |
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) { |