Better implimentation of legend (thanks @zafrirron )
This commit is contained in:
parent
9d904f5b10
commit
3350094154
@ -1,5 +1,6 @@
|
||||
### Change Log for Node-RED Worldmap
|
||||
|
||||
- v2.2.1 - Better implementation of legend create/show/hide
|
||||
- v2.2.0 - Add rangering arcs function
|
||||
- v2.1.6 - Add legend command to allow inserting an html legend
|
||||
- v2.1.5 - Fix squawk icon color handling
|
||||
|
@ -10,6 +10,7 @@ map web page for plotting "things" on.
|
||||
|
||||
### Updates
|
||||
|
||||
- v2.2.1 - Better implementation of legend create/show/hide
|
||||
- v2.2.0 - Add rangerings arcs function
|
||||
- v2.1.6 - Add legend command to allow inserting an html legend
|
||||
- v2.1.5 - Fix squawk icon color handling
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "node-red-contrib-web-worldmap",
|
||||
"version": "2.2.0",
|
||||
"version": "2.2.1",
|
||||
"description": "A Node-RED node to provide a web page of a world map for plotting things on.",
|
||||
"dependencies": {
|
||||
"cgi": "0.3.1",
|
||||
|
@ -1662,15 +1662,22 @@ function doCommand(cmd) {
|
||||
}
|
||||
}
|
||||
if (cmd.hasOwnProperty("legend")) {
|
||||
try { map.removeControl(legend); }
|
||||
catch(e) {}
|
||||
if (typeof cmd.legend === "string" && cmd.legend.length > 0) {
|
||||
legend.onAdd = function() {
|
||||
var div = L.DomUtil.create("div", "legend");
|
||||
div.innerHTML = cmd.legend;
|
||||
return div;
|
||||
if (typeof cmd.legend === "string" && cmd.legend.length > 0) {
|
||||
if (!legend.getContainer()) { //if legend not exist create it
|
||||
legend.onAdd = function() {
|
||||
var div = L.DomUtil.create("div", "legend");
|
||||
div.innerHTML = cmd.legend;
|
||||
return div;
|
||||
};
|
||||
legend.addTo(map);
|
||||
};
|
||||
legend.addTo(map);
|
||||
legend.getContainer().style.visibility = 'visible'; // if already exist use visibility to show/hide
|
||||
legend.getContainer().innerHTML = cmd.legend; // set content of legend
|
||||
}
|
||||
else {
|
||||
if (legend.getContainer()) {
|
||||
legend.getContainer().style.visibility = 'hidden'; //if empty string and legend already created hide it
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user