aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilli <willi@jups42.de>2012-12-01 20:33:48 +0100
committerWilli <willi@jups42.de>2012-12-01 20:33:48 +0100
commitb972c93beebc5a63cfd314977742806469e17183 (patch)
treebb990321e1911bc97f9a086b7f338f86cd309984
parenta3f3baeb1671ebe670ee8f12da1390ed80dc7ee9 (diff)
downloadhealth-map-b972c93beebc5a63cfd314977742806469e17183.tar
health-map-b972c93beebc5a63cfd314977742806469e17183.tar.gz
added template for popup
-rw-r--r--resources/map.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/resources/map.js b/resources/map.js
index 91a9432..3b98003 100644
--- a/resources/map.js
+++ b/resources/map.js
@@ -2,6 +2,12 @@ $(document).ready(function() {
var self = this;
+ self.template = _.template('<dl> <% _.each(properties, function(val, key) { %>\
+ <dt><%= key %> </dt>\
+ <dd><%= val %> </dd>\
+ <% }); %>\
+ </dl>');
+
fetchLayers();
var map = L.map( 'map', {
zoom: 12,
@@ -37,7 +43,7 @@ $(document).ready(function() {
console.log(data);
layer = L.geoJson(data, {
onEachFeature: function(feature, layer) {
- layer.bindPopup(feature.properties);
+ layer.bindPopup(self.template({ properties: feature.properties }));
}
});
self.hospitalLayer.addData(data);
@@ -54,7 +60,7 @@ $(document).ready(function() {
converter.fetch(url, function(data) {
layer = L.geoJson(data, {
onEachFeature: function(feature, layer) {
- layer.bindPopup(JSON.stringify(feature.properties));
+ layer.bindPopup(self.template({ properties: feature.properties }));
}
});
self.hospitalLayer = layer;