node-red-contrib-web-worldmap 4.0.0 → 4.2.1
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 +3 -0
- package/README.md +10 -5
- package/package.json +1 -1
- package/worldmap/leaflet/leaflet.boatmarker.js +1 -1
- package/worldmap/worldmap.js +22 -9
- package/worldmap.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
### Change Log for Node-RED Worldmap
|
|
2
2
|
|
|
3
|
+
- v4.2.1 - Revert use of optional chaining to extend life slightly. Issue #252
|
|
4
|
+
- v4.2.0 - Let icons also be inline images data:image...
|
|
5
|
+
- v4.1.0 - Add optional SOG, COG, altft, altm input properties.
|
|
3
6
|
- v4.0.0 - Breaking - Better context menu variable substitution and retention
|
|
4
7
|
Now uses ${name} syntax rather than $name so we can handle user defined variables in context menus.
|
|
5
8
|
|
package/README.md
CHANGED
|
@@ -13,6 +13,9 @@ Feel free to [
|
|
57
60
|
- **draggable** : set to <i>true</i> to allow marker to be moved by the mouse. (default <i>false</i>)
|
|
58
61
|
- **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.
|
|
62
|
+
- **track | hdg | heading | COG | bearing** : when combined with speed, draws a vector. (only first will be used)
|
|
63
|
+
- **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.
|
|
64
|
+
- **SOG** : speed over ground - speed in knots.
|
|
65
|
+
- **alt | altitude | altft | altm** : Altitude in meters, but can use *altft* to specify feet instead.
|
|
61
66
|
- **accuracy** : when combined with heading vector, draws an arc of possible direction.
|
|
62
67
|
- **color** : CSS color name or #rrggbb value for heading vector line or accuracy polygon.
|
|
63
|
-
- **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.
|
|
68
|
+
- **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:// or inline data:image/ uri.
|
|
64
69
|
- **iconColor** : Standard CSS colour name or #rrggbb hex value.
|
|
65
70
|
- **SIDC** : NATO symbology code (can be used instead of icon). See below.
|
|
66
71
|
- **building** : OSMbulding GeoJSON feature set to add 2.5D buildings to buildings layer. See below.
|
|
@@ -88,7 +93,7 @@ If you use the name without the fa- prefix (eg `male`) you will get the icon ins
|
|
|
88
93
|
|
|
89
94
|
You can also specify an emoji as the icon by using the :emoji name: syntax - for example `:smile:`. Here is a **[list of emojis](https://github.com/dceejay/RedMap/blob/master/emojilist.md)**.
|
|
90
95
|
|
|
91
|
-
Or you can specify an image to load as an icon by setting the icon to http(s)://... By default it will be scaled to 32x32 pixels. You can change the size by setting **iconSize** to a number - eg 64. Example icon - `"https://img.icons8.com/windows/32/000000/bird.png"`
|
|
96
|
+
Or you can specify an image to load as an icon by setting the icon to http(s)://... By default it will be scaled to 32x32 pixels. You can change the size by setting **iconSize** to a number - eg 64. Example icon - `"https://img.icons8.com/windows/32/000000/bird.png"` or you can use an inline image of the form data:image/... which uses a base64 encoded image.
|
|
92
97
|
|
|
93
98
|
There are also several special icons...
|
|
94
99
|
|
package/package.json
CHANGED
package/worldmap/worldmap.js
CHANGED
|
@@ -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*
|
|
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*
|
|
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 ?? "
|
|
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
|
|
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.
|
|
2271
|
-
else if ( re3.test(""+data.speed) ) { data.length = data.length * 0.
|
|
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
|
}
|
package/worldmap.js
CHANGED
|
@@ -126,7 +126,7 @@ module.exports = function(RED) {
|
|
|
126
126
|
if (message.action === "draw") {
|
|
127
127
|
delete message.action;
|
|
128
128
|
delete message.type;
|
|
129
|
-
delete message.options
|
|
129
|
+
if (message.options) { delete message.options.pane; }
|
|
130
130
|
allPoints[message.name] = RED.util.cloneMessage(message);
|
|
131
131
|
sendToRest(message,client.id);
|
|
132
132
|
}
|