diff --git a/sketch/html/app.js b/sketch/html/app.js
index 5364b1d..b93f075 100644
--- a/sketch/html/app.js
+++ b/sketch/html/app.js
@@ -17,22 +17,18 @@ function onMapClick(e){ //for adding a tree(house)
}
function onMapZoom(e){ //for deciding wether to show barrios or treehouses
if (map.getZoom() > max_barrio_zoom) {
- map.addLayer(barrio_markers);
- map.removeLayer(tree_markers);
+ map.addLayer(tree_markers);
+ map.removeLayer(barrio_markers);
}
if (map.getZoom() <= max_barrio_zoom) {
- map.addLayer(tree_markers);
- map.removeLayer(barrio_markers);
+ map.addLayer(barrio_markers);
+ map.removeLayer(tree_markers);
}
}
function onSelectAreaFeatureEnabled(e){
- editing = true;
- editButton.toggle_style();
}
function onSelectAreaFeatureDisabled(e){
- editing = false;
- editButton.toggle_style();
}
function onMapMouseDown(e){} //probably needed for Barrio creation -> nope.
function onMapMouseUp(e){
@@ -67,9 +63,11 @@ map.on('contextMenu', onMapContextMenu);
map.on('selectareadisabled', onSelectAreaFeatureDisabled);
map.on('selectareaenabled', onSelectAreaFeatureEnabled);
sidebar.on('closing', function(e) {
- if(document.getElementById('barrio_form'))
+ if(document.getElementById('barrio_form')) {
sidebar.removePanel('barrio_form');
- if(!document.getElementById('barrio_form'))
- map.selectAreaFeature.enable();
+ // this seems redundant, but I want to check that we removed *the last* of (hopefully, but not guaranteed i guess, only one) barrio_form(s)
+ if(!document.getElementById('barrio_form') && editing && map.getZoom() <= max_barrio_zoom)
+ map.selectAreaFeature.enable();
+ }
});
diff --git a/sketch/html/editButton.js b/sketch/html/editButton.js
index b52e193..75abb6b 100644
--- a/sketch/html/editButton.js
+++ b/sketch/html/editButton.js
@@ -25,20 +25,22 @@ L.Control.EditButton = L.Control.extend({
},
onAdd: function (map) {
+ let ts = this;
this.editButton = L.DomUtil.create('button', 'w3-button w3-white w3-hover-light-blue w3-small leaflet-bar');
this.editButton.innerHTML = 'edit';
this.editButton.title = this.title.inactive();
this.editButton.onclick = function(){
+ let zoom = map.getZoom();
if (editing) {
map.selectAreaFeature.disable();
- // editing = false; // /should/ be redundand
+ editing = false;
} else {
- map.selectAreaFeature.enable();
- // editing = true; // /should/ be redundand
+ if(!document.getElementById('barrio_form') && zoom <= max_barrio_zoom) map.selectAreaFeature.enable();
+ editing = true;
}
- // this.toggle_style(); // /should/ be redundand
+ ts.toggle_style();
};
return this.editButton;