allow loading overlays hidden

to also not trigger addlayer event
to close #108
This commit is contained in:
Dave Conway-Jones 2019-08-16 17:25:45 +01:00
parent 09dfaa052f
commit 5a99aaf57d
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
4 changed files with 27 additions and 9 deletions

View File

@ -1,5 +1,6 @@
### Change Log for Node-RED Worldmap
- v2.0.21 - allow adding overlays without making them visible (visible:false) - Issue #108
- v2.0.20 - ensure `fit` option is boolean, Issue #109. Fix track layers, Issue #110.
- v2.0.18 - Stop map contextmenu bleedthrough to marker. Add compress middleware.
- v2.0.17 - Let clear command also clear tracks from tracks node

View File

@ -9,6 +9,7 @@ map web page for plotting "things" on.
### Updates
- v2.0.21 - allow adding overlays without making them visible (visible:false) - Issue #108
- v2.0.20 - ensure `fit` option is boolean, Issue #109. Fix track layers, Issue #110.
- v2.0.18 - Stop map contextmenu bleedthrough to marker. Add compress middleware.
- v2.0.17 - Let clear command also clear tracks from tracks node
@ -399,6 +400,8 @@ To add an overlay instead of a base layer - specify the `overlay` property inste
"wms": true
}
By default the overlay will be instantly visible. To load it hidden add a property to the command.map - `visible:false`
#### To add a new geoJSON overlay
msg.payload.command.map = {
@ -431,7 +434,7 @@ As per the geojson overlay you can also inject a KML layer, GPX layer or TOPOJSO
- **icon** : <a href="https://fontawesome.com/v4.7.0/icons/" target="mapinfo">font awesome</a> icon name.
- **iconColor** : Standard CSS colour name or #rrggbb hex value.
Again the boolean `fit` property can be added to make the map zoom to the relevant area.
Again the boolean `fit` property can be added to make the map zoom to the relevant area, and the `visible` property can be set false to not immediately show the layer.
#### To add a Velocity Grid Overlay

View File

@ -1,6 +1,6 @@
{
"name": "node-red-contrib-web-worldmap",
"version": "2.0.20",
"version": "2.0.21",
"description": "A Node-RED node to provide a web page of a world map for plotting things on.",
"dependencies": {
"cgi": "0.3.1",

View File

@ -1677,7 +1677,9 @@ function doCommand(cmd) {
if (!existsalready) {
layercontrol.addOverlay(overlays[cmd.map.overlay],cmd.map.overlay);
}
map.addLayer(overlays[cmd.map.overlay]);
if (!cmd.map.hasOwnProperty("visible") || (cmd.map.visible != false)) {
map.addLayer(overlays[cmd.map.overlay]);
}
if (cmd.map.hasOwnProperty("fit") && (cmd.map.fit === true)) { map.fitBounds(overlays[cmd.map.overlay].getBounds()); }
}
// Add a new NVG XML overlay layer
@ -1716,7 +1718,9 @@ function doCommand(cmd) {
if (!existsalready) {
layercontrol.addOverlay(overlays[cmd.map.overlay],cmd.map.overlay);
}
map.addLayer(overlays[cmd.map.overlay]);
if (!cmd.map.hasOwnProperty("visible") || (cmd.map.visible != false)) {
map.addLayer(overlays[cmd.map.overlay]);
}
if (cmd.map.hasOwnProperty("fit")) { map.fitBounds(overlays[cmd.map.overlay].getBounds()); }
}
var custIco = function() {
@ -1747,7 +1751,9 @@ function doCommand(cmd) {
if (!existsalready) {
layercontrol.addOverlay(overlays[cmd.map.overlay],cmd.map.overlay);
}
map.addLayer(overlays[cmd.map.overlay]);
if (!cmd.map.hasOwnProperty("visible") || (cmd.map.visible != false)) {
map.addLayer(overlays[cmd.map.overlay]);
}
if (cmd.map.hasOwnProperty("fit")) { map.fitBounds(overlays[cmd.map.overlay].getBounds()); }
}
// Add a new TOPOJSON overlay layer
@ -1760,7 +1766,9 @@ function doCommand(cmd) {
if (!existsalready) {
layercontrol.addOverlay(overlays[cmd.map.overlay],cmd.map.overlay);
}
map.addLayer(overlays[cmd.map.overlay]);
if (!cmd.map.hasOwnProperty("visible") || (cmd.map.visible != false)) {
map.addLayer(overlays[cmd.map.overlay]);
}
if (cmd.map.hasOwnProperty("fit")) { map.fitBounds(overlays[cmd.map.overlay].getBounds()); }
}
// Add a new GPX overlay layer
@ -1774,7 +1782,9 @@ function doCommand(cmd) {
if (!existsalready) {
layercontrol.addOverlay(overlays[cmd.map.overlay],cmd.map.overlay);
}
map.addLayer(overlays[cmd.map.overlay]);
if (!cmd.map.hasOwnProperty("visible") || (cmd.map.visible != false)) {
map.addLayer(overlays[cmd.map.overlay]);
}
if (cmd.map.hasOwnProperty("fit")) { map.fitBounds(overlays[cmd.map.overlay].getBounds()); }
}
// Add a new velocity overlay layer
@ -1787,7 +1797,9 @@ function doCommand(cmd) {
if (!existsalready) {
layercontrol.addOverlay(overlays[cmd.map.overlay],cmd.map.overlay);
}
map.addLayer(overlays[cmd.map.overlay]);
if (!cmd.map.hasOwnProperty("visible") || (cmd.map.visible != false)) {
map.addLayer(overlays[cmd.map.overlay]);
}
if (cmd.map.hasOwnProperty("fit")) { map.fitBounds(overlays[cmd.map.overlay].getBounds()); }
}
// Add a new overlay layer
@ -1814,7 +1826,9 @@ function doCommand(cmd) {
if (!existsalready) {
layercontrol.addOverlay(overlays[cmd.map.overlay],cmd.map.overlay);
}
map.addLayer(overlays[cmd.map.overlay]);
if (!cmd.map.hasOwnProperty("visible") || (cmd.map.visible != false)) {
map.addLayer(overlays[cmd.map.overlay]);
}
}
// Swap a base layer
if (cmd.layer && basemaps.hasOwnProperty(cmd.layer)) {