diff options
-rw-r--r-- | resources/map.js | 16 |
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 © <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; |