aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilli <willi@jups42.de>2012-12-02 13:15:14 +0100
committerWilli <willi@jups42.de>2012-12-02 13:15:14 +0100
commitd9e20235bb4840e4346b164f39292780ce67cbc9 (patch)
treec1982879c79930fca3d995f5e23da2a858f623ae
parente53fff6ea95fd6fabfead99f141cd5c53e14e124 (diff)
downloadhealth-map-d9e20235bb4840e4346b164f39292780ce67cbc9.tar
health-map-d9e20235bb4840e4346b164f39292780ce67cbc9.tar.gz
checkboxes only for boolean attributes
-rw-r--r--resources/map.js23
1 files changed, 13 insertions, 10 deletions
diff --git a/resources/map.js b/resources/map.js
index 50fdd87..52962f3 100644
--- a/resources/map.js
+++ b/resources/map.js
@@ -27,7 +27,7 @@ $(document).ready(function() {
GlobalMap = map;
function addHospitalLayer(){
- L.control.layers(null, {
+ self.layers = L.control.layers(null, {
"Hospitals" : self.hospitalLayer
}).addTo(map);
// display layer
@@ -63,21 +63,26 @@ $(document).ready(function() {
function buildLayer(data) {
return L.geoJson(data, {
- onEachFeature: function(feature, layer) {
- storeAllAttributeKeys(feature);
- layer.bindPopup(self.popupTemplate({ properties: feature.properties }));
- }
+ onEachFeature: function(feature, layer) {
+ storeBooleanAttributeKeys(feature);
+ layer.bindPopup(self.popupTemplate({ properties: feature.properties }));
+ },
});
}
- function storeAllAttributeKeys(feature) {
+ function storeBooleanAttributeKeys(feature) {
var isHierarchical = new RegExp('\:');
+
+ function isBoolean (val) {
+ return val === 'yes' || val === 'no';
+ }
+
var keys = _.keys(feature.properties);
_.each(feature.properties, function(val, key) {
if (isHierarchical.exec(key)) {
key = key.split(':')[1];
}
- if (!_.contains(self.hospitalAttributes, key)) {
+ if (!_.contains(self.hospitalAttributes, key) && isBoolean(val)) {
self.hospitalAttributes.push(key);
}
});
@@ -116,15 +121,13 @@ $(document).ready(function() {
$('.filter-box').html(t);
_.each($('.filter-box input'), function(el) {
//first check them all
- el.click();
+ // el.click();
// attach click handler
$(el).click(checkedFilterBox);
- $(el).dblclick(dontZoom);
});
}
function checkedFilterBox(event) {
- _(self.currentFilter).without(event.currentTarget.value);
var prev = self.hospitalLayer;
// L.control.layers(null, {
// "Hospitals" : TODO qgitnew Layer