Allow layer command of none to remove base layer

This commit is contained in:
Dave Conway-Jones 2019-03-11 15:48:31 +00:00
parent 4c7a0dd2c3
commit a2bdd32364
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
3 changed files with 10 additions and 2 deletions

View File

@ -323,6 +323,10 @@ style server by adding a property `wms: true`. (see overlay example below)
"opt":{ "maxZoom":19, "attribution":"© OpenStreetMap" } "opt":{ "maxZoom":19, "attribution":"© OpenStreetMap" }
}; };
Note: you can use the name "none" to completely remove the base layer for example.
msg.payload = {"command":{"layer":"none"}};
#### To add a WMS overlay layer - eg US weather radar #### To add a WMS overlay layer - eg US weather radar
To add an overlay instead of a base layer - specify the `overlay` property instead of the `name`. To add an overlay instead of a base layer - specify the `overlay` property instead of the `name`.

View File

@ -1379,7 +1379,7 @@ function setMarker(data) {
marker.bindPopup(words, {closeButton:false, closeOnClick:false, keepInView:true, minWidth:250}); marker.bindPopup(words, {closeButton:false, closeOnClick:false, keepInView:true, minWidth:250});
marker._popup.dname = data.name; marker._popup.dname = data.name;
marker.lay = lay; // and the layer it is on marker.lay = lay; // and the layer it is on
var rightmenuMarker = L.popup({offset:[0,-12]}).setContent("<b>"+data.name+"</b><br/><button id='delbutton' onclick='delMarker(\""+data.name+"\",true);'>Delete</button>"); var rightmenuMarker = L.popup({offset:[0,-12]}).setContent("<b>"+data.name+"</b><br/><button id='delbutton' onclick='delMarker(\""+data.name+"\",true);'>Delete</button>");
marker.on('contextmenu', function(e) { marker.on('contextmenu', function(e) {
if (hiderightclick !== true) { if (hiderightclick !== true) {
@ -1756,6 +1756,10 @@ function doCommand(cmd) {
baselayername = cmd.layer; baselayername = cmd.layer;
basemaps[baselayername].addTo(map); basemaps[baselayername].addTo(map);
} }
if (cmd.layer && (cmd.layer === "none")) {
map.removeLayer(basemaps[baselayername]);
baselayername = cmd.layer;
}
// Add search command // Add search command
if (cmd.hasOwnProperty("search") && (typeof cmd.search === "string")) { if (cmd.hasOwnProperty("search") && (typeof cmd.search === "string")) {
document.getElementById('search').value = cmd.search; document.getElementById('search').value = cmd.search;

View File

@ -1,5 +1,5 @@
CACHE MANIFEST CACHE MANIFEST
# date: Mar 2nd 2019 - v1.5.29c # date: Mar 2nd 2019 - v1.5.29d
CACHE: CACHE:
index.html index.html