Allow show/hidelayer to add multiple overlyas in one go

To close #53
This commit is contained in:
Dave Conway-Jones 2018-10-22 22:09:56 +01:00
parent 0e7484263c
commit 24f3a066ba
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
4 changed files with 26 additions and 11 deletions

View File

@ -1,6 +1,7 @@
### Change Log for Node-RED Worldmap
- v1.5.4 - allow remote update of the split position via `msg.command.split`
- v1.5.5 - Allow multiple overlays to be enabled at once - Issue #53
- v1.5.4 - Allow remote update of the split position via `msg.command.split`
- v1.5.3 - Add side by side mode (via `msg.command` only).
- v1.5.2 - Make manually added icons moveable by default.
- v1.5.0 - Add multi-map capability - can now have multiple map endpoints. Issue #40 PR #51

View File

@ -9,7 +9,8 @@ map web page for plotting "things" on.
### Updates
- v1.5.4 - allow remote update of the split position via `msg.command.split`
- v1.5.5 - Allow multiple overlays to be enabled at once - Issue #53
- v1.5.4 - Allow remote update of the split position via `msg.command.split`
- v1.5.3 - Add side by side mode (via `msg.command` only).
- v1.5.2 - Make manually added icons moveable by default.
- v1.5.0 - Add multi-map capability - can now have multiple map endpoints.
@ -245,8 +246,8 @@ Optional properties include
- **lon** - move map to specified longitude.
- **zoom** - move map to specified zoom level (1 - world, 13 to 20 max zoom depending on map).
- **layer** - set map to specified base layer name - `{command:{layer:"Esri"}}`
- **showlayer** - show the named overlay - `{command:{showlayer:"foo"}}`
- **hidelayer** - hide the named overlay - `{command:{hidelayer:"bar"}}`
- **showlayer** - show the named overlay(s) - `{command:{showlayer:"foo"}}` or `{command:{showlayer:["foo","bar"]}}`
- **hidelayer** - hide the named overlay(s) - `{command:{hidelayer:"bar"}}` or `{command:{hidelayer:["bar","another"}}`
- **side** - add a second map alongside with slide between them. Use the name of the *baselayer* to add - or "none" to remove the control. - `{command:{side:"Esri Satellite"}}`
- **split** - once you have split the screen - the split value is the % across the screen of the split line. - `{command:{split:50}}`
- **map** - Object containing details of a new map layer:

View File

@ -1506,13 +1506,26 @@ function doCommand(cmd) {
sidebyside.lay = cmd.side;
}
if (cmd.split && sidebyside && (cmd.split <= 100) && (cmd.split >= 0)) { console.log("DING",cmd.split); sidebyside.setSplit(cmd.split); }
// Turn on an existing overlay
if (cmd.hasOwnProperty("showlayer") && overlays.hasOwnProperty(cmd.showlayer)) {
map.addLayer(overlays[cmd.showlayer]);
// Turn on an existing overlay(s)
if (cmd.hasOwnProperty("showlayer")) {
if (typeof cmd.showlayer === "string") { cmd.showlayer = [ cmd.showlayer ]; }
console.log(typeof cmd.showlayer,cmd.showlayer);
for (var i=0; i < cmd.showlayer.length; i++) {
console.log(cmd.showlayer[i]);
if (overlays.hasOwnProperty(cmd.showlayer[i])) {
console.log("DING");
map.addLayer(overlays[cmd.showlayer[i]]);
}
}
}
// Turn off an existing overlay(s)
if (cmd.hasOwnProperty("hidelayer")) {
if (typeof cmd.hidelayer === "string") { cmd.hidelayer = [ cmd.hidelayer ]; }
for (var i=0; i < cmd.hidelayer.length; i++) {
if (overlays.hasOwnProperty(cmd.hidelayer[i])) {
map.removeLayer(overlays[cmd.hidelayer[i]]);
}
}
// Turn off an existing overlay
if (cmd.hasOwnProperty("hidelayer") && overlays.hasOwnProperty(cmd.hidelayer)) {
map.removeLayer(overlays[cmd.hidelayer]);
}
var clat = map.getCenter().lat;
var clon = map.getCenter().lng;

View File

@ -1,5 +1,5 @@
CACHE MANIFEST
# date: Oct 17th 2018 - v1.5.4
# date: Oct 17th 2018 - v1.5.5
CACHE:
index.html