diff options
author | Christopher Baines <cbaines8@gmail.com> | 2013-02-07 10:49:53 +0000 |
---|---|---|
committer | Christopher Baines <cbaines8@gmail.com> | 2013-02-07 10:49:53 +0000 |
commit | 9073049284c1aa64fa74e41face555b3a8ae1d78 (patch) | |
tree | 7d271a8dd1037bc3db17721c880a6ef36241d8e8 | |
parent | 57d851b3bad13db30d233ac70a651a110fa04d3f (diff) | |
download | health-map-9073049284c1aa64fa74e41face555b3a8ae1d78.tar health-map-9073049284c1aa64fa74e41face555b3a8ae1d78.tar.gz |
Fix the popup updating bug.
-rw-r--r-- | resources/map.js | 17 |
1 files 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) + - '<div id="' + catchmentArea.id + '">' + - self.catchmentAreaTemplate(catchmentAreaProperties(catchmentArea, feature)) + - '</div>'); + 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))); } } |