node-red-contrib-web-worldmap 5.1.2 → 5.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,6 @@
1
1
  ### Change Log for Node-RED Worldmap
2
2
 
3
+ - v5.1.4 - Fix clearlayer for tracks node.
3
4
  - v5.1.2 - Fix for longer line msg properties.
4
5
  - v5.1.1 - Fix CoT inline image.
5
6
  - v5.1.0 - Let special icons be sizeable using iconSize property.
package/README.md CHANGED
@@ -13,6 +13,7 @@ Feel free to [![](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%
13
13
 
14
14
  ### Updates
15
15
 
16
+ - v5.1.4 - Fix clearlayer for tracks node.
16
17
  - v5.1.2 - Fix for longer line msg properties.
17
18
  - v5.1.1 - Fix CoT inline image.
18
19
  - v5.1.0 - Let special icons be sizeable using iconSize property.
@@ -25,27 +26,7 @@ Feel free to [![](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%
25
26
  - v5.0.2 - Fix sidcEdgeIcon docs PR#289.
26
27
  - v5.0.1 - Fix isArray error PR #288.
27
28
  - v5.0.0 - v5.0.0 - Feedback cleanup PR#281, edgeicons option PR#287, bump libs for vuln fixes.
28
- - v4.9.0 - If payload.flag is two char ISO code replace it with flag emoji. Revert part of PR #271
29
- - v4.8.1 - Slight tidy of some of the geojson handling
30
- - v4.8.0 - Merged PR for feedback functionality cleanup and example. PR #271 and #272
31
- - v4.7.0 - Update pmtiles library, fix feedback function inconsistency. Issue #270
32
- - v4.6.5 - Let geojson allow for generic overrides with .icon and .layer.
33
- - v4.6.4 - Fix deletion of layers logic to actually fully remove points.
34
- - v4.6.3 - Fix sending of layer events when not wanted. Issue #262
35
- - v4.6.2 - Fix multiple use of contextmenu feedback. Issue #259
36
- - v4.6.1 - Let default pmtiles be light/dark or monocolored.
37
- - v4.5.2 - Tidy up when pmtiles removed.
38
- - v4.5.0 - Fix pmtiles to look for maps in userdir rather than modules
39
- - v4.4.0 - Add quad(copter) drone icon.
40
- - v4.3.3 - Fix for objects changing layers.
41
- - v4.3.2 - Fix geojson popup missing label name.
42
- - v4.3.1 - Small fix to icon transparency, and routing detail.
43
- - v4.3.0 - Add support for PMtiles files.
44
- - v4.2.1 - Revert use of optional chaining to extend life slightly. Issue #252
45
- - v4.2.0 - Let icons also be inline images data:image...
46
- - v4.1.0 - Add optional SOG, COG, altft, altm input properties.
47
- - v4.0.0 - Breaking - Better context menu variable substitution and retention
48
- Now uses ${name} syntax rather than $name so we can handle user defined variables in context menus.
29
+
49
30
 
50
31
  - see [CHANGELOG](https://github.com/dceejay/RedMap/blob/master/CHANGELOG.md) for full list of changes.
51
32
 
@@ -723,7 +704,7 @@ There are some internal functions available to make interacting with Node-RED ea
723
704
 
724
705
  - **addToForm()** : takes a property name value pair to add to a variable called `form`. When used with contextmenu feedback (above) you can set the feedback value to `"_form"` to substitute this accumulated value. This allows you to do things like `onBlur='addToForm(this.name,this.value)'` over several different fields in the menu and then use `feedback(this.name,"_form")` to submit them all at once. For example a simple multiple line form could be as per the example below:
725
706
 
726
- Also if you wish to retain the values between separate openings of this form you can assign property names to the value field in the form `value="${foo}`, etc. These will then appear as part of an **value** property on the worldmap-in node message.
707
+ Retain Values - If you wish to retain the values between separate openings of this form you can assign property names to the value field in the form `value="${foo}`, etc. These will then appear as part of an **value** property on the worldmap-in node message.
727
708
 
728
709
  ```
729
710
  var menu = 'Add some data <input name="foo" value="${foo}" onchange=\'addToForm(this.name,this.value)\'></input><br/>'
@@ -732,6 +713,23 @@ menu += '<button name="my_form" onclick=\'feedback(this.name,"_form","formAction
732
713
  msg.payload = { command: { "contextmenu":menu } }
733
714
  ```
734
715
 
716
+ Custom Feedback Content - The example below shows how you can pass the latitude and longitude location value from the contextmenu popup when right clicking the map. You can also use this method with other data you wish.
717
+
718
+ ```
719
+ var menu ='<center><br/>';
720
+ menu += 'Add some data <input type="text" id="foo" placeholder="foo"><br/>';
721
+ menu += 'Add more data <input type="text" id="bar" placeholder="bar"><br/>';
722
+ menu += '<input type="button" value="Submit" onclick=';
723
+ menu += '\'feedback("myform",{';
724
+ menu += '"foo":document.getElementById("foo").value,';
725
+ menu += '"bar":document.getElementById("bar").value,';
726
+ menu += '"lat":rclk.lat.toFixed(12),';
727
+ menu += '"lon":rclk.lng.toFixed(12),';
728
+ menu += '},"formAction",true)\' > <br/><br/> ';
729
+ msg.payload = { command: { "contextmenu":menu } }
730
+ ```
731
+ For a more detailed example flow using this method see: [Moving Icons Demo & Builder](https://github.com/dceejay/RedMap/blob/master/examples/Moving%20Icons%20Demo%20%26%20Builder.json)
732
+
735
733
  - **delMarker()** : takes the name of the marker as a parameter. In a popup this can be specified as `${name}` for dynamic substitution.
736
734
 
737
735
  - **editPoly()** : takes the name of the shape or line as a parameter. In a popup this can be specified as `${name}` for dynamic substitution.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-web-worldmap",
3
- "version": "5.1.2",
3
+ "version": "5.1.4",
4
4
  "description": "A Node-RED node to provide a web page of a world map for plotting things on.",
5
5
  "dependencies": {
6
6
  "@turf/bezier-spline": "~7.2.0",
@@ -18,7 +18,7 @@ var menuOpen = false;
18
18
  var clusterAt = 0;
19
19
  var maxage = 900; // default max age of icons on map in seconds - cleared after 15 mins
20
20
  var baselayername = "OSM grey"; // Default base layer OSM but uniform grey
21
- var pagefoot = "&nbsp;&copy; DCJ 2023";
21
+ var pagefoot = "&nbsp;&copy; DCJ 2025";
22
22
  var inIframe = false;
23
23
  var showUserMenu = true;
24
24
  var showLayerMenu = true;
@@ -3346,7 +3346,7 @@ function doGeojson(n,g,l,o,i) { // name, geojson, layer, options, icon
3346
3346
  // handle TAK messages from TAK server tcp - XML->JSON
3347
3347
  function doTAKjson(p) {
3348
3348
  //console.log("TAK event",p);
3349
- if (p.type.indexOf('a-') === 0 || p.type.indexOf('b-m-p-') === 0 || p.type.indexOf('b-a-o-') === 0 || p.type.indexOf('b-a-g') === 0) {
3349
+ if (p?.type && (p.type.indexOf('a-') === 0 || p.type.indexOf('b-m-p-') === 0 || p.type.indexOf('b-a-o-') === 0 || p.type.indexOf('b-a-g') === 0)) {
3350
3350
  var d = {};
3351
3351
  d.name = p.detail?.contact?.callsign || p.uid;
3352
3352
  d.lat = Number(p.point.lat);
@@ -3395,14 +3395,14 @@ function doTAKjson(p) {
3395
3395
  setMarker(d);
3396
3396
  }
3397
3397
  else {
3398
- console.log("Skip TAK type",p.type);
3398
+ console.log("Skip TAK type",p?.type);
3399
3399
  }
3400
3400
  }
3401
3401
 
3402
3402
  // handle TAK messages from TAK Multicast - Protobuf->JSON
3403
3403
  function doTAKMCjson(p) {
3404
3404
  // console.log("TAK Multicast event",p);
3405
- if (p.type.indexOf('a') === 0) {
3405
+ if (p?.type && p.type.indexOf('a') === 0) {
3406
3406
  var d = {};
3407
3407
  d.lat = p.lat;
3408
3408
  d.lon = p.lon;
@@ -3438,7 +3438,7 @@ function doTAKMCjson(p) {
3438
3438
  setMarker(d);
3439
3439
  }
3440
3440
  else {
3441
- console.log("Skip TAK type",p.type);
3441
+ console.log("Skip TAK type",p?.type);
3442
3442
  }
3443
3443
  }
3444
3444
 
package/worldmap.js CHANGED
@@ -402,6 +402,7 @@ module.exports = function(RED) {
402
402
 
403
403
  var doTrack = function(msg) {
404
404
  if (msg.hasOwnProperty("payload") && msg.payload.hasOwnProperty("name")) {
405
+ if (!msg.payload.layer) { msg.payload.layer = "unknown"; }
405
406
  var newmsg = RED.util.cloneMessage(msg);
406
407
  if (msg.payload.deleted) {
407
408
  if (msg.payload.name.substr(-1) === '_') {
@@ -474,9 +475,13 @@ module.exports = function(RED) {
474
475
  newmsg.payload.layer = newmsg.payload.layer.substr(1);
475
476
  }
476
477
  }
477
- if (node.layer === "single") {
478
+ else if (node.layer === "single") {
478
479
  newmsg.payload.layer = "Tracks";
479
480
  }
481
+ else {
482
+ newmsg.payload.layer = msg.payload.layer;
483
+
484
+ }
480
485
  node.send(newmsg); // send the track
481
486
  }
482
487
  }
@@ -494,7 +499,7 @@ module.exports = function(RED) {
494
499
  }
495
500
  }
496
501
  if (msg.payload?.command?.clear) {
497
- if (!isArray(msg.payload?.command?.clear)) {
502
+ if (!Array.isArray(msg.payload?.command?.clear)) {
498
503
  msg.payload.command.clear = [ msg.payload.command.clear ]
499
504
  }
500
505
  msg.payload.command.clear.forEach(function(el) {
@@ -508,7 +513,7 @@ module.exports = function(RED) {
508
513
  })
509
514
  }
510
515
  if (msg.payload?.command?.clearlayer) {
511
- if (!isArray(msg.payload?.command?.clearlayer)) {
516
+ if (!Array.isArray(msg.payload?.command?.clearlayer)) {
512
517
  msg.payload.command.clearlayer = [ msg.payload.command.clearlayer ]
513
518
  }
514
519
  msg.payload.command.clearlayer.forEach(function(el) {