From b6bbdb64ef56b60255c40cef6cf1e90061e59632 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Fri, 6 Oct 2023 18:38:34 +0100 Subject: [PATCH] ensure delete drawing appears under drawing events --- worldmap.html | 3 ++- worldmap.js | 4 ++-- worldmap/worldmap.js | 7 ++++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/worldmap.html b/worldmap.html index ac710af..940cad3 100644 --- a/worldmap.html +++ b/worldmap.html @@ -617,6 +617,7 @@ If Web Path is left empty, then by default ⌘⇧m - c
  • delete - when a point or shape is deleted
  • point - when a point is added manually using right-click
  • draw - when a shape is added manually to the drawing layer
  • +
  • drawdelete - when a shape is deleted from the drawing layer
  • layer - when a base layer is changed
  • addlayer - when an overlay is added to the map
  • dellayer - when an overlay is removed from the map
  • @@ -662,10 +663,10 @@ If Web Path is left empty, then by default ⌘⇧m - c { value: "connect", label: "Connect"}, { value: "disconnect", label: "Disconnect"}, { value: "point", label: "Add, move, delete point"}, + { value: "draw", label: "Add, edit or delete drawing"}, { value: "layer", label: "Add, remove layers"}, { value: "bounds", label: "Boundary change"}, { value: "files", label: "File drop"}, - { value: "draw", label: "Drawing"}, { value: "other", label: "All other"} ] }]}); diff --git a/worldmap.js b/worldmap.js index fd305bf..c261145 100644 --- a/worldmap.js +++ b/worldmap.js @@ -139,7 +139,7 @@ module.exports = function(RED) { delete message.from; sendToRest(message,client.id); } - if (message.action === "delete") { + if (message.action === "delete" || message.action === "drawdelete") { delete allPoints[message.name]; sendToRest(message,client.id); } @@ -313,7 +313,7 @@ module.exports = function(RED) { message.content = Buffer.from(message.content.split('base64,')[1], 'base64'); setImmediate(function() {node.send({payload:message, topic:node.path.substr(1), _sessionid:client.id, _sessionip:sessionip})}); } - if ((node.events.indexOf("draw")!==-1) && (message.action === "draw")) { + if ((node.events.indexOf("draw")!==-1) && ((message.action === "draw")||(message.action === "drawdelete"))) { setImmediate(function() {node.send({payload:message, topic:node.path.substr(1), _sessionid:client.id, _sessionip:sessionip})}); } if (node.events.indexOf("other")!==-1 && "connected,point,delete,move,draw,files,bounds".indexOf(message.action) === -1) { diff --git a/worldmap/worldmap.js b/worldmap/worldmap.js index 17d70c9..8b2c3c2 100644 --- a/worldmap/worldmap.js +++ b/worldmap/worldmap.js @@ -1384,9 +1384,11 @@ helpText += 'The default is that only visible layers add to the heatmap.

    '; // Delete a marker or shape (and notify websocket) var delMarker = function(dname,note) { if (note) { map.closePopup(); } + var pol = false; if (typeof polygons[dname] != "undefined") { layers[polygons[dname].lay].removeLayer(polygons[dname]); delete polygons[dname]; + pol = true; } if (typeof polygons[dname+"_"] != "undefined") { layers[polygons[dname+"_"].lay].removeLayer(polygons[dname+"_"]); @@ -1402,7 +1404,10 @@ var delMarker = function(dname,note) { delete markers[dname]; } delete allData[dname]; - if (note) { ws.send(JSON.stringify({action:"delete", name:dname, deleted:true})); } + if (note) { + if (pol === false) { ws.send(JSON.stringify({action:"delete", name:dname, deleted:true})); } + else { ws.send(JSON.stringify({action:"drawdelete", name:dname, deleted:true}))} + } } var editPoly = function(pname,fun) {