aboutsummaryrefslogtreecommitdiff
path: root/resources
diff options
context:
space:
mode:
authorChristopher Baines <cbaines8@gmail.com>2013-02-15 10:47:34 +0000
committerChristopher Baines <cbaines8@gmail.com>2013-02-15 10:47:34 +0000
commitaf54d6f83f8d51f5528c53056ff41bbeaabf319d (patch)
tree241a6e3b6647c4ea7f7cce2bb015343f440d9d26 /resources
parent2632c35998f720580d455b1cc959f25dfa795658 (diff)
downloadhealth-map-af54d6f83f8d51f5528c53056ff41bbeaabf319d.tar
health-map-af54d6f83f8d51f5528c53056ff41bbeaabf319d.tar.gz
Fix a bug with missing tags
Diffstat (limited to 'resources')
-rw-r--r--resources/map.js16
1 files changed, 15 insertions, 1 deletions
diff --git a/resources/map.js b/resources/map.js
index 1298c73..17cf48d 100644
--- a/resources/map.js
+++ b/resources/map.js
@@ -122,6 +122,18 @@ function catchmentAreaProperties(catchmentArea, healthPost) {
return areaProperties;
}
+function fillObjectWithUnknowns(object, expectedProperties) {
+ var newObject = {};
+ _.each(expectedProperties, function(property) {
+ if (_.isUndefined(object[property])) {
+ newObject[property] = "Unknown";
+ } else {
+ newObject[property] = object[property];
+ }
+ });
+ return newObject;
+}
+
function initMap(self) {
var tileUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
var tileAttribution = 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors';
@@ -231,8 +243,10 @@ function initMap(self) {
var catchmentArea = self.catchmentAreas[feature.id];
+ var healthPostProperties = fillObjectWithUnknowns(feature.properties, ["name", "emergency"]);
+
layer.bindPopup(self.editorTemplate({coordinate: center}) +
- self.healthPostTemplate(feature.properties) +
+ self.healthPostTemplate(healthPostProperties) +
self.catchmentAreaTemplate(catchmentAreaProperties(catchmentArea, feature)));
self.markers[feature.id] = layer;