From 9073049284c1aa64fa74e41face555b3a8ae1d78 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Thu, 7 Feb 2013 10:49:53 +0000 Subject: Fix the popup updating bug. --- resources/map.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/resources/map.js b/resources/map.js index 8159514..42eea93 100644 --- a/resources/map.js +++ b/resources/map.js @@ -221,9 +221,7 @@ function initMap(self) { layer.bindPopup(self.editorTemplate({coordinate: center}) + self.healthPostTemplate(feature.properties) + - '
' + - self.catchmentAreaTemplate(catchmentAreaProperties(catchmentArea, feature)) + - '
'); + self.catchmentAreaTemplate(catchmentAreaProperties(catchmentArea, feature))); self.markers[feature.id] = layer; }, @@ -329,7 +327,18 @@ function displayMap(self, map) { }); self.settlementsLayerGroup.addLayer(self.catchmentAreaSettlementsLayers[catchmentArea.id]); - $('#' + catchmentArea.id).html(self.catchmentAreaTemplate(catchmentAreaProperties(catchmentArea, self.healthPosts[catchmentArea.properties["subject"]]))); + var healthPost = self.healthPosts[catchmentArea.properties.subject]; + + var center; + if (healthPost.geometry.type === "Point") { + center = healthPost.geometry.coordinates; + } else { + center = healthPost.geometry.coordinates[0]; + } + + self.markers[catchmentArea.properties.subject].bindPopup(self.editorTemplate({coordinate: center}) + + self.healthPostTemplate(healthPost.properties) + + self.catchmentAreaTemplate(catchmentAreaProperties(catchmentArea, healthPost))); } } -- cgit v1.2.3