Let heatmap be completely replaced

This commit is contained in:
Dave Conway-Jones 2022-12-13 15:45:27 +00:00
parent 1bdc44f4f9
commit 23a0aa12e1
No known key found for this signature in database
GPG Key ID: 88BA2B8A411BE9FF
4 changed files with 12 additions and 7 deletions

View File

@ -1,5 +1,6 @@
### Change Log for Node-RED Worldmap ### Change Log for Node-RED Worldmap
- v2.32.1 - Let command.heatmap replace complete heatmap array.
- v2.32.0 - Change || to nullish operator ?? to fix numerous dodgy assignments. Issue #219 - v2.32.0 - Change || to nullish operator ?? to fix numerous dodgy assignments. Issue #219
Delete marker now also removes from heatmap layer. Issue #218 Delete marker now also removes from heatmap layer. Issue #218

View File

@ -11,6 +11,7 @@ map web page for plotting "things" on.
### Updates ### Updates
- v2.32.1 - Let command.map.heatmap replace complete heatmap array.
- v2.32.0 - Change || to nullish operator ?? to fix numerous dodgy assignments. Issue #219 - v2.32.0 - Change || to nullish operator ?? to fix numerous dodgy assignments. Issue #219
Delete marker now also removes from heatmap layer. Issue #218 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.3 - Undo previous fix as while more technically correct - doesn't look so good. Issue #217
@ -410,7 +411,8 @@ Optional properties include
- **wms** - true/false/grey, specifies if the data is provided by a Web Map Service (if grey sets layer to greyscale) - **wms** - true/false/grey, specifies if the data is provided by a Web Map Service (if grey sets layer to greyscale)
- **bounds** - sets the bounds of an Overlay-Image. 2 Dimensional Array that defines the top-left and bottom-right Corners (lat/lon Points) - **bounds** - sets the bounds of an Overlay-Image. 2 Dimensional Array that defines the top-left and bottom-right Corners (lat/lon Points)
- **delete** - name or array of names of base layers and/or overlays to delete and remove from layer menu. - **delete** - name or array of names of base layers and/or overlays to delete and remove from layer menu.
- **heatmap** - set heatmap options object see https://github.com/Leaflet/Leaflet.heat#reference - **heatmap** - set heatmap latlngs array object see https://github.com/Leaflet/Leaflet.heat#reference
- **options** - if heatmap set, then use this to set heatmap options object see https://github.com/Leaflet/Leaflet.heat#reference
- **clear** - layer name - to clear a complete layer and remove from layer menu - `{"command":{"clear":"myOldLayer"}}` - **clear** - layer name - to clear a complete layer and remove from layer menu - `{"command":{"clear":"myOldLayer"}}`
- **panlock** - lock the map area to the current visible area. - `{"command":{"panlock":true}}` - **panlock** - lock the map area to the current visible area. - `{"command":{"panlock":true}}`
- **panit** - auto pan to the latest marker updated. - `{"command":{"panit":true}}` - **panit** - auto pan to the latest marker updated. - `{"command":{"panit":true}}`

View File

@ -1,6 +1,6 @@
{ {
"name": "node-red-contrib-web-worldmap", "name": "node-red-contrib-web-worldmap",
"version": "2.32.0", "version": "2.32.1",
"description": "A Node-RED node to provide a web page of a world map for plotting things on.", "description": "A Node-RED node to provide a web page of a world map for plotting things on.",
"dependencies": { "dependencies": {
"@turf/bezier-spline": "~6.5.0", "@turf/bezier-spline": "~6.5.0",

View File

@ -2584,7 +2584,6 @@ function doCommand(cmd) {
overlays[cmd.map.overlay].addTo(map); overlays[cmd.map.overlay].addTo(map);
} }
} }
// Swap a base layer // Swap a base layer
if (cmd.layer && basemaps.hasOwnProperty(cmd.layer)) { if (cmd.layer && basemaps.hasOwnProperty(cmd.layer)) {
map.removeLayer(basemaps[baselayername]); map.removeLayer(basemaps[baselayername]);
@ -2668,10 +2667,13 @@ function doCommand(cmd) {
document.getElementById("maxage").value = cmd.maxage; document.getElementById("maxage").value = cmd.maxage;
setMaxAge(); setMaxAge();
} }
if (cmd.hasOwnProperty("heatmap")) { // Replace heatmap layer with new array (and optionally options)
heat.setOptions(cmd.heatmap); if (cmd.hasOwnProperty("heatmap") && heat) {
document.getElementById("heatall").checked = !!cmd.heatmap; if (cmd.hasOwnProperty("options")) { heat.setOptions(cmd.options); }
heat.redraw(); heat.setLatLngs(cmd.heatmap);
// heat.setOptions(cmd.heatmap);
// document.getElementById("heatall").checked = !!cmd.heatmap;
// heat.redraw();
} }
if (cmd.hasOwnProperty("panlock") && lockit === true) { doLock(true); } if (cmd.hasOwnProperty("panlock") && lockit === true) { doLock(true); }
if (cmd.hasOwnProperty("zoomlock")) { if (cmd.hasOwnProperty("zoomlock")) {