aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilli <willi@jups42.de>2012-12-02 11:19:35 +0100
committerWilli <willi@jups42.de>2012-12-02 11:19:35 +0100
commitee738141231340095b9cccaec53c2192d690384b (patch)
treea9147b99e77a00f3318c86adfcbcc0cabd33b156
parent3e74e6f135496a3e8b756b9a4cab13854324c044 (diff)
downloadhealth-map-ee738141231340095b9cccaec53c2192d690384b.tar
health-map-ee738141231340095b9cccaec53c2192d690384b.tar.gz
removed duplicate checkboxes
-rw-r--r--resources/map.js31
1 files changed, 21 insertions, 10 deletions
diff --git a/resources/map.js b/resources/map.js
index 938e08a..50fdd87 100644
--- a/resources/map.js
+++ b/resources/map.js
@@ -24,6 +24,7 @@ $(document).ready(function() {
zoom: 12,
layers: [self.tileLayer],
});
+ GlobalMap = map;
function addHospitalLayer(){
L.control.layers(null, {
@@ -52,6 +53,7 @@ $(document).ready(function() {
var url = "http://overpass-api.de/api/interpreter?data=[out:json];node[amenity=hospital](" + bbox + ");out;";
converter = new op2geojson();
converter.fetch(url, function(data) {
+ self.hospitals = data;
layer = buildLayer(data)
self.hospitalLayer.addData(data);
});
@@ -62,24 +64,31 @@ $(document).ready(function() {
function buildLayer(data) {
return L.geoJson(data, {
onEachFeature: function(feature, layer) {
- var isHierarchical = new RegExp('\:');
- _.each(feature.properties, function(val, key) {
- if (isHierarchical.exec(isHierarchical)) {
- key = key.split(':')[1];
- if (_.contains(self.hospitalAttributes), key) {
- self.hospitalAttributes.push(key);
- }
- }
- });
+ storeAllAttributeKeys(feature);
layer.bindPopup(self.popupTemplate({ properties: feature.properties }));
}
});
}
+ function storeAllAttributeKeys(feature) {
+ var isHierarchical = new RegExp('\:');
+ var keys = _.keys(feature.properties);
+ _.each(feature.properties, function(val, key) {
+ if (isHierarchical.exec(key)) {
+ key = key.split(':')[1];
+ }
+ if (!_.contains(self.hospitalAttributes, key)) {
+ self.hospitalAttributes.push(key);
+ }
+ });
+ self.hospitalAttributes;
+ }
+
function geojsonLayer() {
url = "http://overpass-api.de/api/interpreter?data=[out:json];node[amenity=hospital](52.34,13.3,52.52,13.6);out;";
converter = new op2geojson();
converter.fetch(url, function(data) {
+ self.hospitals = data;
layer = buildLayer(data);
self.hospitalLayer = layer;
map.fireEvent('hospitalsfetched');
@@ -98,7 +107,7 @@ $(document).ready(function() {
}
});
var template = _.template('<div><form> <% _.each(attributes, function (attr) { %> \
- <input type="checkbox" name=<%=attr %> value=<%= attr %>> <%= attr %> \
+ <label><input type="checkbox" name=<%=attr %> value=<%= attr %>> <%= attr %> </label> \
<% }); %> \
</form></div>');
var t = template({ attributes: self.hospitalAttributes });
@@ -108,7 +117,9 @@ $(document).ready(function() {
_.each($('.filter-box input'), function(el) {
//first check them all
el.click();
+ // attach click handler
$(el).click(checkedFilterBox);
+ $(el).dblclick(dontZoom);
});
}