From 1bdc44f4f91f7439fe234d348219857d718f9b01 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Tue, 13 Dec 2022 14:40:36 +0000 Subject: [PATCH] delete markers from heatmap when removed. to close #218 bump for release --- CHANGELOG.md | 5 ++++- README.md | 4 +++- package.json | 2 +- worldmap/worldmap.js | 10 ++++++++-- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aad51e5..d0ec9cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ ### Change Log for Node-RED Worldmap - - v2.33.3 - Undo previous fix as while more technically correct - doesn't look so good. Issue #217 + - v2.32.0 - Change || to nullish operator ?? to fix numerous dodgy assignments. Issue #219 + Delete marker now also removes from heatmap layer. Issue #218 + + - v2.31.3 - Undo previous fix as while more technically correct - doesn't look so good. Issue #217 - v2.31.2 = Fix more antimeridian crossing wrinkles. Issue #216 - v2.31.1 - Fix missing type property for drawings, and pass back feedback value. Add route distance. Issue #213, Issue #212, PR #215 - v2.31.0 - Better handling of KML files. Issue #211 diff --git a/README.md b/README.md index 0951bfe..834cbb9 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,9 @@ map web page for plotting "things" on. ### Updates -- v2.33.3 - Undo previous fix as while more technically correct - doesn't look so good. Issue #217 +- v2.32.0 - Change || to nullish operator ?? to fix numerous dodgy assignments. Issue #219 + Delete marker now also removes from heatmap layer. Issue #218 +- v2.31.3 - Undo previous fix as while more technically correct - doesn't look so good. Issue #217 - v2.31.2 = Fix more antimeridian crossing wrinkles. Issue #216 - v2.31.1 - Fix missing type property for drawings, and pass back feedback value. Add route distance. Issue #213, Issue #212, PR #215 - v2.31.0 - Better handling of KML files. Issue #211 diff --git a/package.json b/package.json index 30ca1e9..a808987 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-red-contrib-web-worldmap", - "version": "2.31.3", + "version": "2.32.0", "description": "A Node-RED node to provide a web page of a world map for plotting things on.", "dependencies": { "@turf/bezier-spline": "~6.5.0", diff --git a/worldmap/worldmap.js b/worldmap/worldmap.js index 6edbb61..669493e 100644 --- a/worldmap/worldmap.js +++ b/worldmap/worldmap.js @@ -1214,9 +1214,13 @@ var addOverlays = function(overlist) { }); } - // Add the heatmap layer + // Add the heatmap layer (and add delete LatLng function) if (overlist.indexOf("HM")!==-1) { heat = L.heatLayer([], {radius:60, gradient:{0.2:'blue', 0.4:'lime', 0.6:'red', 0.8:'yellow', 1:'white'}}); + heat.delLatLng = function(ll) { + heat._latlngs = heat._latlngs.filter(v => { return v != ll; } ); + heat._redraw(); + } layers["_heat"] = new L.LayerGroup().addLayer(heat); overlays["heatmap"] = layers["_heat"]; } @@ -1276,6 +1280,9 @@ var delMarker = function(dname,note) { delete polygons[dname+"_"]; } if (typeof markers[dname] != "undefined") { + if (heat && markers[dname].hasOwnProperty("_latlng")) { + heat.delLatLng(markers[dname]._latlng); + } layers[markers[dname].lay].removeLayer(markers[dname]); map.removeLayer(markers[dname]); delete markers[dname]; @@ -1333,7 +1340,6 @@ var rangerings = function(latlng, options) { // the MAIN add something to map function function setMarker(data) { - var rightmenu = function(m) { // customise right click context menu var rightcontext = "";