fix deleting hulls cleanly
This commit is contained in:
parent
6595aa7dd6
commit
f9b6c6743a
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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",
|
||||
|
27
worldmap.js
27
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;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user