diff options
author | Willi <willi@jups42.de> | 2012-12-01 20:33:48 +0100 |
---|---|---|
committer | Willi <willi@jups42.de> | 2012-12-01 20:33:48 +0100 |
commit | b972c93beebc5a63cfd314977742806469e17183 (patch) | |
tree | bb990321e1911bc97f9a086b7f338f86cd309984 | |
parent | a3f3baeb1671ebe670ee8f12da1390ed80dc7ee9 (diff) | |
download | health-map-b972c93beebc5a63cfd314977742806469e17183.tar health-map-b972c93beebc5a63cfd314977742806469e17183.tar.gz |
added template for popup
-rw-r--r-- | resources/map.js | 10 |
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; |