diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e2d54e..f0c76f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ### Change Log for Node-RED Worldmap + - v2.5.4 - Fix delete of hulls + - v2.5.3 - Swap default satellite layer - v2.5.2 - Add boolean parameter to feedback call to allow auto close of popup on click. Set Esc key to close all open popups. Issue #146 - v2.5.1 - Add lat, lng and layer to feedback function. - v2.5.0 - Add minimap capability. diff --git a/README.md b/README.md index 0b3b5f2..26ea030 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ map web page for plotting "things" on. ### Updates +- v2.5.4 - Fix delete of hulls +- v2.5.3 - Swap default satellite layer - v2.5.2 - Add boolean parameter to feedback call to allow auto close of popup on click. Set Esc key to close all open popups. Issue #146 - v2.5.1 - Add lat, lng and layer to feedback function. - v2.5.0 - Add minimap capability. diff --git a/package.json b/package.json index f0d210f..8d7935b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-red-contrib-web-worldmap", - "version": "2.5.3", + "version": "2.5.4", "description": "A Node-RED node to provide a web page of a world map for plotting things on.", "dependencies": { "cgi": "0.3.1", diff --git a/worldmap.js b/worldmap.js index 20d57f7..ce47d68 100644 --- a/worldmap.js +++ b/worldmap.js @@ -371,6 +371,7 @@ module.exports = function(RED) { RED.nodes.createNode(this,n); this.prop = n.prop || "layer"; var node = this; + var oldl = 0; node.hulls = {}; var convexHull = function(points) { @@ -423,15 +424,31 @@ module.exports = function(RED) { var convexHullPoints = convexHull(node.hulls[newmsg.payload[node.prop]]); var leafletHull = convexHullPoints.map(function (element) {return ([element.lat,element.lon])}) - if (leafletHull.length > 1) { - // if (leafletHull.length === 2) { newmsg.payload.line = leafletHull; } - // else { - newmsg.payload.area = leafletHull; - // } - newmsg.payload.name = newmsg.payload[node.prop]; - newmsg.payload.clickable = true; + newmsg.payload.name = newmsg.payload[node.prop]; + newmsg.payload.clickable = true; + + if (leafletHull.length === 1 && oldl === 2) { + newmsg.payload.deleted = true; node.send(newmsg); } + if (leafletHull.length === 2 && (oldl === 1 || oldl ===3)) { + newmsg.payload.deleted = true; + node.send(newmsg); + delete newmsg.payload.deleted; + newmsg.payload.line = leafletHull; + node.send(newmsg); + } + if (leafletHull.length === 3 && oldl === 2) { + newmsg.payload.deleted = true; + node.send(newmsg); + delete newmsg.payload.deleted; + } + if (leafletHull.length >= 3) { + newmsg.payload.area = leafletHull; + node.send(newmsg); + } + + oldl = leafletHull.length; } }