node-red-contrib-web-worldmap 4.0.0 → 4.2.0

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,7 @@
1
1
  ### Change Log for Node-RED Worldmap
2
2
 
3
+ - v4.2.0 - Let icons also be inline images data:image...
4
+ - v4.1.0 - Add optional SOG, COG, altft, altm input properties.
3
5
  - v4.0.0 - Breaking - Better context menu variable substitution and retention
4
6
  Now uses ${name} syntax rather than $name so we can handle user defined variables in context menus.
5
7
 
package/README.md CHANGED
@@ -13,6 +13,8 @@ Feel free to [![](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%
13
13
 
14
14
  ### Updates
15
15
 
16
+ - v4.2.0 - Let icons also be inline images data:image...
17
+ - v4.1.0 - Add optional SOG, COG, altft, altm input properties.
16
18
  - v4.0.0 - Breaking - Better context menu variable substitution and retention
17
19
  Now uses ${name} syntax rather than $name so we can handle user defined variables in context menus.
18
20
  - v3.2.0 - Sync up drawing sessions across browsers to same map
@@ -49,15 +51,17 @@ The minimum **msg.payload** must contain `name`, `lat` and `lon` properties, for
49
51
 
50
52
  msg.payload = { "name":"Jason", "lat":51.05, "lon":-1.35 }
51
53
 
52
- `name` must be a unique identifier across the whole map. Repeated location updates to the same `name` move the marker.
54
+ `name` **must** be a unique identifier across the whole map. Repeated location updates to the same `name` move the marker.
53
55
 
54
56
  Optional properties for **msg.payload** include
55
57
 
56
58
  - **deleted** : set to <i>true</i> to remove the named marker. (default <i>false</i>)
57
59
  - **draggable** : set to <i>true</i> to allow marker to be moved by the mouse. (default <i>false</i>)
58
60
  - **layer** : specify a layer on the map to add marker to. (default <i>"unknown"</i>)
59
- - **track | hdg | heading | bearing** : when combined with speed, draws a vector. (only first will be used)
60
- - **speed** : when combined with track, hdg, heading, or bearing, draws a leader line vector.
61
+ - **track | hdg | heading | COG | bearing** : when combined with speed, draws a vector. (only first will be used)
62
+ - **speed** : when combined with track, hdg, heading, or bearing, draws a leader line vector - should be in m/s. Can also be specified as "20 kph", or "20 mph", or "20 kt". i.e a string with units.
63
+ - **SOG** : speed over ground - speed in knots.
64
+ - **alt | altitude | altft | altm** : Altitude in meters, but can use *altft* to specify feet instead.
61
65
  - **accuracy** : when combined with heading vector, draws an arc of possible direction.
62
66
  - **color** : CSS color name or #rrggbb value for heading vector line or accuracy polygon.
63
67
  - **icon** : <a href="https://fontawesome.com/v4.7.0/icons/" target="mapinfo">font awesome</a> icon name, <a href="https://github.com/Paul-Reed/weather-icons-lite" target="mapinfo">weather-lite</a> icon, :emoji name:, or https:// uri.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-web-worldmap",
3
- "version": "4.0.0",
3
+ "version": "4.2.0",
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": "~6.5.0",
@@ -7,7 +7,7 @@
7
7
  /* BOAT ICON */
8
8
  L.BoatIcon = L.Icon.extend({
9
9
  options: {
10
- iconSize: new L.Point(50, 50),
10
+ iconSize: new L.Point(52, 52),
11
11
  className: "leaflet-boat-icon",
12
12
  course: 0,
13
13
  color: "#8ED6FF",
@@ -327,7 +327,7 @@ var errRing;
327
327
  function onLocationFound(e) {
328
328
  if (followState === true) { map.panTo(e.latlng); }
329
329
  if (followMode.icon) {
330
- var self = {name:followMode.name || "self", lat:e.latlng.lat, lon:e.latlng.lng, hdg:e.heading, speed:(e.speed*3.6 ?? undefined), layer:followMode.layer, icon:followMode.icon, iconColor:followMode.iconColor ?? "#910000" };
330
+ var self = {name:followMode.name || "self", lat:e.latlng.lat, lon:e.latlng.lng, hdg:e.heading, speed:(e.speed*1 ?? undefined), layer:followMode.layer, icon:followMode.icon, iconColor:followMode.iconColor ?? "#910000" };
331
331
  setMarker(self);
332
332
  }
333
333
  if (e.heading !== null) { map.setBearing(e.heading); }
@@ -342,7 +342,7 @@ function onLocationFound(e) {
342
342
  // L.polygon([ e.latlng, lla ], {color:"00ffff", weight:3, opacity:0.5, clickable:false}).addTo(map);
343
343
  // }
344
344
  }
345
- ws.send(JSON.stringify({action:"point", lat:e.latlng.lat.toFixed(5), lon:e.latlng.lng.toFixed(5), point:"self", hdg:e.heading, speed:(e.speed*3.6 ?? undefined)}));
345
+ ws.send(JSON.stringify({action:"point", lat:e.latlng.lat.toFixed(5), lon:e.latlng.lng.toFixed(5), point:"self", hdg:e.heading, speed:(e.speed*1 ?? undefined)}));
346
346
  }
347
347
 
348
348
  function onLocationError(e) { console.log(e.message); }
@@ -1750,7 +1750,7 @@ function setMarker(data) {
1750
1750
  if (data.icon === "ship") {
1751
1751
  marker = L.boatMarker(ll, {
1752
1752
  title: data.name,
1753
- color: (data.iconColor ?? "blue")
1753
+ color: (data.iconColor ?? "#5DADE2")
1754
1754
  });
1755
1755
  marker.setHeading(dir);
1756
1756
  q = 'https://www.bing.com/images/search?q='+data.icon+'%20%2B"'+encodeURIComponent(data.name)+'"';
@@ -1974,7 +1974,7 @@ function setMarker(data) {
1974
1974
  marker = L.marker(ll, {title:data.name, icon:myMarker, draggable:drag});
1975
1975
  labelOffset = [12,-4];
1976
1976
  }
1977
- else if (data.icon.match(/^https?:.*$|^\//)) { // web url icon https://...
1977
+ else if (data.icon.match(/^https?:.*$|^\/|^data:image\//)) { // web url icon https://...
1978
1978
  var sz = data.iconSize ?? 32;
1979
1979
  myMarker = L.icon({
1980
1980
  iconUrl: data.icon,
@@ -2113,6 +2113,16 @@ function setMarker(data) {
2113
2113
  data.alt = +(parseFloat(data.alt)).toFixed(2);
2114
2114
  }
2115
2115
  }
2116
+ if (data.hasOwnProperty("altft")) {
2117
+ data.alt = +(parseFloat(data.altft)).toFixed(2) + " ft";
2118
+ delete data.altft;
2119
+ }
2120
+ if (data.hasOwnProperty("altm")) {
2121
+ data.alt = +(parseFloat(data.altm)).toFixed(2) + " m";
2122
+ delete data.altm;
2123
+ }
2124
+ if (data.sog) { data.speed = data.sog * 0.514444; data.sog = data.sog + " kt"; } // SOG is in knots
2125
+ if (data.SOG) { data.speed = data.SOG * 0.514444; data.SOG = data.SOG + " kt"; } // SOG is in knots
2116
2126
 
2117
2127
  // remove items from list of properties, then add all others to popup
2118
2128
  if (data.hasOwnProperty("options")) { delete data.options; }
@@ -2198,7 +2208,9 @@ function setMarker(data) {
2198
2208
  // Delete more already handled properties
2199
2209
  var llc = data.lineColor ?? data.color;
2200
2210
  delete data.lat;
2211
+ delete data.latitude;
2201
2212
  delete data.lon;
2213
+ delete data.longitude;
2202
2214
  if (data.arc) { delete data.arc; }
2203
2215
  if (data.layer) { delete data.layer; }
2204
2216
  if (data.lineColor) { delete data.lineColor; }
@@ -2259,16 +2271,17 @@ function setMarker(data) {
2259
2271
  // else if (data.bearing !== undefined) { track = data.bearing; }
2260
2272
 
2261
2273
  // Now add any leader lines
2262
- var track = data.track ?? data.hdg ?? data.heading ?? data.bearing;
2274
+ var track = data.track ?? data.COG ?? data.cog ?? data.hdg ?? data.heading ?? data.bearing;
2263
2275
  if (track != undefined) { // if there is a heading
2276
+ // Speed is in m/s
2264
2277
  if (data.speed != null && data.length === undefined) { // and a speed - lets convert to a leader length
2265
2278
  data.length = parseFloat(data.speed || "0") * 60;
2266
- var re1 = new RegExp('kn|knot|kt','i');
2279
+ var re1 = new RegExp('kn|knot|kt|kts','i');
2267
2280
  var re2 = new RegExp('kph|kmh','i');
2268
2281
  var re3 = new RegExp('mph','i');
2269
2282
  if ( re1.test(""+data.speed) ) { data.length = data.length * 0.514444; }
2270
- else if ( re2.test(""+data.speed) ) { data.length = data.length * 0.44704; }
2271
- else if ( re3.test(""+data.speed) ) { data.length = data.length * 0.277778; }
2283
+ else if ( re2.test(""+data.speed) ) { data.length = data.length * 0.277778; }
2284
+ else if ( re3.test(""+data.speed) ) { data.length = data.length * 0.44704; }
2272
2285
  }
2273
2286
  if (data.length !== undefined) {
2274
2287
  if (polygons[data.name] != null && !polygons[data.name].hasOwnProperty("_layers")) {
@@ -2939,7 +2952,7 @@ function doCommand(cmd) {
2939
2952
  if (cmd.hasOwnProperty("rotation") && !isNaN(cmd.rotation)) {
2940
2953
  map.setBearing(-cmd.rotation);
2941
2954
  for (const item in allData) {
2942
- if (allData[item].hasOwnProperty("hdg") || allData[item].hasOwnProperty("heading") || allData[item].hasOwnProperty("bearing") || allData[item].hasOwnProperty("track")) {
2955
+ if (allData[item].hasOwnProperty("hdg") || allData[item].hasOwnProperty("heading") || allData[item].hasOwnProperty("bearing") || allData[item].hasOwnProperty("track") || allData[item].hasOwnProperty("cog") || allData[item].hasOwnProperty("COG")) {
2943
2956
  setMarker(allData[item]);
2944
2957
  }
2945
2958
  }