node-red-contrib-web-worldmap 2.21.0 → 2.21.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 +4 -0
- package/README.md +4 -6
- package/node_modules/websocket-driver/lib/websocket/driver/base.js +0 -2
- package/package.json +1 -1
- package/worldmap/index.html +1 -0
- package/worldmap/leaflet/L.TileLayer.PixelFilter.js +152 -0
- package/worldmap/worldmap.js +48 -17
- package/worldmap/worldmaphead.html +1 -0
- package/worldmap.html +2 -2
- package/worldmap.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
### Change Log for Node-RED Worldmap
|
|
2
2
|
|
|
3
|
+
- v2.21.4 - fix speed leader length. Add transparentPixels option.
|
|
4
|
+
- v2.21.3 - Add zoom to bounds action. Adjust map layers max zoom levels.
|
|
5
|
+
- v2.21.2 - Expand ship nav to ship navigation.
|
|
6
|
+
- v2.21.1 - Fix ui check callback to not use .
|
|
3
7
|
- v2.21.0 - Let config panel select maps to show, default map and choice of overlays.
|
|
4
8
|
- v2.20.0 - Add support of .pbf map layers. Issue #123.
|
|
5
9
|
- v2.19.0 - Bump leaflet to latest. v1.7
|
package/README.md
CHANGED
|
@@ -11,6 +11,10 @@ map web page for plotting "things" on.
|
|
|
11
11
|
|
|
12
12
|
### Updates
|
|
13
13
|
|
|
14
|
+
- v2.21.4 - fix speed leader length. Add transparentPixels option..
|
|
15
|
+
- v2.21.3 - Add zoom to bounds action. Adjust map layers max zoom levels.
|
|
16
|
+
- v2.21.2 - Expand ship nav to ship navigation.
|
|
17
|
+
- v2.21.1 - Fix ui check callback to not use .
|
|
14
18
|
- v2.21.0 - Let config panel select maps to show, default map and choice of overlays.
|
|
15
19
|
- v2.20.0 - Add support of .pbf map layers. Issue 123.
|
|
16
20
|
- v2.19.1 - Add filter for bounds events only.
|
|
@@ -30,12 +34,6 @@ map web page for plotting "things" on.
|
|
|
30
34
|
- v2.15.3 - Fix panit command to work, try to use alt units, popup alignments.
|
|
31
35
|
- v2.15.0 - Let speed be text and specify units if required (kt,kn,knots,mph,kmh,kph) default m/s.
|
|
32
36
|
- v2.14.0 - Let geojson features be clickable if added as overlay.
|
|
33
|
-
- v2.13.4 - Fix list of map choices to be in sync. Fix popup auto sizing.
|
|
34
|
-
- v2.13.3 - Fix unchanged layer propagation.
|
|
35
|
-
- v2.13.2 - Add mayflower icon.
|
|
36
|
-
- v2.13.0 - Tidy velocity layer. Feedback any url parameters.
|
|
37
|
-
- v2.12.1 - Only show online layer options if we are online.
|
|
38
|
-
- v2.12.0 - Add live rainfall radar data layer. Remove some non-loading overlays.
|
|
39
37
|
|
|
40
38
|
- see [CHANGELOG](https://github.com/dceejay/RedMap/blob/master/CHANGELOG.md) for full list of changes.
|
|
41
39
|
|
|
@@ -37,10 +37,8 @@ Base.isWebSocket = function(request) {
|
|
|
37
37
|
|
|
38
38
|
Base.validateOptions = function(options, validKeys) {
|
|
39
39
|
for (var key in options) {
|
|
40
|
-
if (options.hasOwnProperty(key)) {
|
|
41
40
|
if (validKeys.indexOf(key) < 0)
|
|
42
41
|
throw new Error('Unrecognized option: ' + key);
|
|
43
|
-
}
|
|
44
42
|
}
|
|
45
43
|
};
|
|
46
44
|
|
package/package.json
CHANGED
package/worldmap/index.html
CHANGED
|
@@ -72,6 +72,7 @@
|
|
|
72
72
|
<script src="leaflet/leaflet.latlng-graticule.js"></script>
|
|
73
73
|
<script src="leaflet/VectorTileLayer.umd.min.js"></script>
|
|
74
74
|
<script src="leaflet/Semicircle.js"></script>
|
|
75
|
+
<script src="leaflet/L.TileLayer.PixelFilter.js"></script>
|
|
75
76
|
<script src="leaflet/dialog-polyfill.js"></script>
|
|
76
77
|
|
|
77
78
|
<script src="images/emoji.js"></script>
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* L.TileLayer.PixelFilter
|
|
3
|
+
* https://github.com/greeninfo/L.TileLayer.PixelFilter
|
|
4
|
+
* http://greeninfo-network.github.io/L.TileLayer.PixelFilter/
|
|
5
|
+
*/
|
|
6
|
+
L.tileLayerPixelFilter = function (url, options) {
|
|
7
|
+
return new L.TileLayer.PixelFilter(url, options);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
L.TileLayer.PixelFilter = L.TileLayer.extend({
|
|
11
|
+
// the constructor saves settings and throws a fit if settings are bad, as typical
|
|
12
|
+
// then adds the all-important 'tileload' event handler which basically "detects" an unmodified tile and performs the pxiel-swap
|
|
13
|
+
initialize: function (url, options) {
|
|
14
|
+
options = L.extend({}, L.TileLayer.prototype.options, {
|
|
15
|
+
matchRGBA: null,
|
|
16
|
+
missRGBA: null,
|
|
17
|
+
pixelCodes: [],
|
|
18
|
+
crossOrigin: 'Anonymous', // per issue 15, this is how you do it in Leaflet 1.x
|
|
19
|
+
}, options);
|
|
20
|
+
L.TileLayer.prototype.initialize.call(this, url, options);
|
|
21
|
+
L.setOptions(this, options);
|
|
22
|
+
|
|
23
|
+
// go ahead and save our settings
|
|
24
|
+
this.setMatchRGBA(this.options.matchRGBA);
|
|
25
|
+
this.setMissRGBA(this.options.missRGBA);
|
|
26
|
+
this.setPixelCodes(this.options.pixelCodes);
|
|
27
|
+
|
|
28
|
+
// and add our tile-load event hook which triggers us to do the pixel-swap
|
|
29
|
+
this.on('tileload', function (event) {
|
|
30
|
+
this.applyFiltersToTile(event.tile);
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
// settings setters
|
|
35
|
+
setMatchRGBA: function (rgba) {
|
|
36
|
+
// save the setting
|
|
37
|
+
if (rgba !== null && (typeof rgba !== 'object' || typeof rgba.length !== 'number' || rgba.length !== 4) ) throw "L.TileLayer.PixelSwap expected matchRGBA to be RGBA [r,g,b,a] array or else null";
|
|
38
|
+
this.options.matchRGBA = rgba;
|
|
39
|
+
|
|
40
|
+
// force a redraw, which means new tiles, which mean new tileload events; the circle of life
|
|
41
|
+
this.redraw(true);
|
|
42
|
+
},
|
|
43
|
+
setMissRGBA: function (rgba) {
|
|
44
|
+
// save the setting
|
|
45
|
+
if (rgba !== null && (typeof rgba !== 'object' || typeof rgba.length !== 'number' || rgba.length !== 4) ) throw "L.TileLayer.PixelSwap expected missRGBA to be RGBA [r,g,b,a] array or else null";
|
|
46
|
+
this.options.missRGBA = rgba;
|
|
47
|
+
|
|
48
|
+
// force a redraw, which means new tiles, which mean new tileload events; the circle of life
|
|
49
|
+
this.redraw(true);
|
|
50
|
+
},
|
|
51
|
+
setPixelCodes: function (pixelcodes) {
|
|
52
|
+
// save the setting
|
|
53
|
+
if (typeof pixelcodes !== 'object' || typeof pixelcodes.length !== 'number') throw "L.TileLayer.PixelSwap expected pixelCodes to be a list of triplets: [ [r,g,b], [r,g,b], ... ]";
|
|
54
|
+
this.options.pixelCodes = pixelcodes;
|
|
55
|
+
|
|
56
|
+
// force a redraw, which means new tiles, which mean new tileload events; the circle of life
|
|
57
|
+
this.redraw(true);
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
// extend the _createTile function to add the .crossOrigin attribute, since loading tiles from a separate service is a pretty common need
|
|
61
|
+
// and the Canvas is paranoid about cross-domain image data. see issue #5
|
|
62
|
+
// this is really only for Leaflet 0.7; as of 1.0 L.TileLayer has a crossOrigin setting which we define as a layer option
|
|
63
|
+
_createTile: function () {
|
|
64
|
+
var tile = L.TileLayer.prototype._createTile.call(this);
|
|
65
|
+
tile.crossOrigin = "Anonymous";
|
|
66
|
+
return tile;
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
// the heavy lifting to do the pixel-swapping
|
|
70
|
+
// called upon 'tileload' and passed the IMG element
|
|
71
|
+
// tip: when the tile is saved back to the IMG element that counts as a tileload event too! thus an infinite loop, as wel as comparing the pixelCodes against already-replaced pixels!
|
|
72
|
+
// so, we tag the already-swapped tiles so we know when to quit
|
|
73
|
+
// if the layer is redrawn, it's a new IMG element and that means it would not yet be tagged
|
|
74
|
+
applyFiltersToTile: function (imgelement) {
|
|
75
|
+
// already processed, see note above
|
|
76
|
+
if (imgelement.getAttribute('data-PixelFilterDone')) return;
|
|
77
|
+
|
|
78
|
+
// copy the image data onto a canvas for manipulation
|
|
79
|
+
var width = imgelement.width;
|
|
80
|
+
var height = imgelement.height;
|
|
81
|
+
var canvas = document.createElement("canvas");
|
|
82
|
+
canvas.width = width;
|
|
83
|
+
canvas.height = height;
|
|
84
|
+
var context = canvas.getContext("2d");
|
|
85
|
+
context.drawImage(imgelement, 0, 0);
|
|
86
|
+
|
|
87
|
+
// create our target imagedata
|
|
88
|
+
var output = context.createImageData(width, height);
|
|
89
|
+
|
|
90
|
+
// extract out our RGBA trios into separate numbers, so we don't have to use rgba[i] a zillion times
|
|
91
|
+
var matchRGBA = this.options.matchRGBA, missRGBA = this.options.missRGBA;
|
|
92
|
+
if (matchRGBA !== null) {
|
|
93
|
+
var match_r = matchRGBA[0], match_g = matchRGBA[1], match_b = matchRGBA[2], match_a = matchRGBA[3];
|
|
94
|
+
}
|
|
95
|
+
if (missRGBA !== null) {
|
|
96
|
+
var miss_r = missRGBA[0], miss_g = missRGBA[1], miss_b = missRGBA[2], miss_a = missRGBA[3];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// go over our pixel-code list and generate the list of integers that we'll use for RGB matching
|
|
100
|
+
// 1000000*R + 1000*G + B = 123123123 which is an integer, and finding an integer inside an array is a lot faster than finding an array inside an array
|
|
101
|
+
var pixelcodes = [];
|
|
102
|
+
for (var i=0, l=this.options.pixelCodes.length; i<l; i++) {
|
|
103
|
+
var value = 1000000 * this.options.pixelCodes[i][0] + 1000 * this.options.pixelCodes[i][1] + this.options.pixelCodes[i][2];
|
|
104
|
+
pixelcodes.push(value);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// iterate over the pixels (each one is 4 bytes, RGBA)
|
|
108
|
+
// and see if they are on our list (recall the "addition" thing so we're comparing integers in an array for performance)
|
|
109
|
+
// per issue #5 catch a failure here, which is likely a cross-domain problem
|
|
110
|
+
try {
|
|
111
|
+
var pixels = context.getImageData(0, 0, width, height).data;
|
|
112
|
+
} catch(e) {
|
|
113
|
+
throw "L.TileLayer.PixelFilter getImageData() failed. Likely a cross-domain issue?";
|
|
114
|
+
}
|
|
115
|
+
for(var i = 0, n = pixels.length; i < n; i += 4) {
|
|
116
|
+
var r = pixels[i ];
|
|
117
|
+
var g = pixels[i+1];
|
|
118
|
+
var b = pixels[i+2];
|
|
119
|
+
var a = pixels[i+3];
|
|
120
|
+
|
|
121
|
+
// bail condition: if the alpha is 0 then it's already transparent, likely nodata, and we should skip it
|
|
122
|
+
if (a == 0) {
|
|
123
|
+
output.data[i ] = 255;
|
|
124
|
+
output.data[i+1] = 255;
|
|
125
|
+
output.data[i+2] = 255;
|
|
126
|
+
output.data[i+3] = 0;
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// default to matching, so that if we are not in fact filtering by code it's an automatic hit
|
|
131
|
+
// number matching trick: 1000000*R + 1000*G + 1*B = 123,123,123 a simple number that either is or isn't on the list
|
|
132
|
+
var match = true;
|
|
133
|
+
if (pixelcodes.length) {
|
|
134
|
+
var sum = 1000000 * r + 1000 * g + b;
|
|
135
|
+
if (-1 === pixelcodes.indexOf(sum)) match = false;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// did it match? either way we push a R, a G, and a B onto the image blob
|
|
139
|
+
// if the target RGBA is a null, then we push exactly the same RGBA as we found in the source pixel
|
|
140
|
+
output.data[i ] = match ? (matchRGBA===null ? r : match_r) : (missRGBA===null ? r : miss_r);
|
|
141
|
+
output.data[i+1] = match ? (matchRGBA===null ? g : match_g) : (missRGBA===null ? g : miss_g);
|
|
142
|
+
output.data[i+2] = match ? (matchRGBA===null ? b : match_b) : (missRGBA===null ? b : miss_b);
|
|
143
|
+
output.data[i+3] = match ? (matchRGBA===null ? a : match_a) : (missRGBA===null ? a : miss_a);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// write the image back to the canvas, and assign its base64 back into the on-screen tile to visualize the change
|
|
147
|
+
// tag the tile as having already been updated, so we don't process a 'load' event again and re-process a tile that surely won't match any target RGB codes, in an infinite loop!
|
|
148
|
+
context.putImageData(output, 0, 0);
|
|
149
|
+
imgelement.setAttribute('data-PixelFilterDone', true);
|
|
150
|
+
imgelement.src = canvas.toDataURL();
|
|
151
|
+
}
|
|
152
|
+
});
|
package/worldmap/worldmap.js
CHANGED
|
@@ -110,7 +110,12 @@ var handleData = function(data) {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
if (data.command) { doCommand(data.command); delete data.command; }
|
|
113
|
-
if (data.hasOwnProperty("type") && data.type.indexOf("Feature") === 0) {
|
|
113
|
+
if (data.hasOwnProperty("type") && data.type.indexOf("Feature") === 0) {
|
|
114
|
+
if (data.hasOwnProperty('properties') && data.properties.hasOwnProperty('title')) {
|
|
115
|
+
doGeojson(data.properties.title,data)
|
|
116
|
+
}
|
|
117
|
+
else { doGeojson("geojson",data); }
|
|
118
|
+
}
|
|
114
119
|
else if (data.hasOwnProperty("name")) { setMarker(data); }
|
|
115
120
|
else {
|
|
116
121
|
if (JSON.stringify(data) !== '{}') {
|
|
@@ -593,7 +598,7 @@ map.on('baselayerchange', function(e) {
|
|
|
593
598
|
});
|
|
594
599
|
|
|
595
600
|
function showMapCurrentZoom() {
|
|
596
|
-
//console.log("
|
|
601
|
+
//console.log("ZOOM:",map.getZoom());
|
|
597
602
|
for (var l in layers) {
|
|
598
603
|
if (layers[l].hasOwnProperty("_zoom")) {
|
|
599
604
|
if (map.getZoom() >= clusterAt) {
|
|
@@ -635,12 +640,12 @@ map.on('zoomend', function() {
|
|
|
635
640
|
showMapCurrentZoom();
|
|
636
641
|
window.localStorage.setItem("lastzoom", map.getZoom());
|
|
637
642
|
var b = map.getBounds();
|
|
638
|
-
ws.send(JSON.stringify({action:"bounds", south:b._southWest.lat, west:b._southWest.lng, north:b._northEast.lat, east:b._northEast.lng }));
|
|
643
|
+
ws.send(JSON.stringify({action:"bounds", south:b._southWest.lat, west:b._southWest.lng, north:b._northEast.lat, east:b._northEast.lng, zoom:map.getZoom() }));
|
|
639
644
|
});
|
|
640
645
|
map.on('moveend', function() {
|
|
641
646
|
window.localStorage.setItem("lastpos",JSON.stringify(map.getCenter()));
|
|
642
647
|
var b = map.getBounds();
|
|
643
|
-
ws.send(JSON.stringify({action:"bounds", south:b._southWest.lat, west:b._southWest.lng, north:b._northEast.lat, east:b._northEast.lng }));
|
|
648
|
+
ws.send(JSON.stringify({action:"bounds", south:b._southWest.lat, west:b._southWest.lng, north:b._northEast.lat, east:b._northEast.lng, zoom:map.getZoom() }));
|
|
644
649
|
});
|
|
645
650
|
|
|
646
651
|
//map.on('contextmenu', function(e) {
|
|
@@ -735,7 +740,7 @@ var addBaseMaps = function(maplist,first) {
|
|
|
735
740
|
//console.log("MAPS",first,maplist)
|
|
736
741
|
if (navigator.onLine) {
|
|
737
742
|
var layerlookup = { OSMG:"OSM grey", OSMC:"OSM", OSMH:"OSM Humanitarian", EsriC:"Esri", EsriS:"Esri Satellite",
|
|
738
|
-
EsriT:"Esri Topography", EsriO:"Esri Ocean", EsriDG:"Esri Dark Grey", NatGeo: "National Geographic",
|
|
743
|
+
EsriR:"Esri Relief", EsriT:"Esri Topography", EsriO:"Esri Ocean", EsriDG:"Esri Dark Grey", NatGeo: "National Geographic",
|
|
739
744
|
UKOS:"UK OS OpenData", UKOS45:"UK OS 1919-1947", UKOS00:"UK OS 1900", OpTop:"Open Topo Map",
|
|
740
745
|
HB:"Hike Bike OSM", ST:"Stamen Topography", SW: "Stamen Watercolor", AN:"AutoNavi (Chinese)" }
|
|
741
746
|
|
|
@@ -794,21 +799,24 @@ var addBaseMaps = function(maplist,first) {
|
|
|
794
799
|
if (maplist.indexOf("EsriR")!==-1) {
|
|
795
800
|
basemaps[layerlookup["EsriR"]] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/{z}/{y}/{x}', {
|
|
796
801
|
attribution:'Tiles © Esri',
|
|
797
|
-
maxNativeZoom:13
|
|
802
|
+
maxNativeZoom:13,
|
|
803
|
+
maxZoom:16
|
|
798
804
|
});
|
|
799
805
|
}
|
|
800
806
|
|
|
801
807
|
if (maplist.indexOf("EsriO")!==-1) {
|
|
802
808
|
basemaps[layerlookup["EsriO"]] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer/tile/{z}/{y}/{x}', {
|
|
803
809
|
attribution:'Tiles © Esri — Sources: GEBCO, NOAA, CHS, OSU, UNH, CSUMB, National Geographic, DeLorme, NAVTEQ, and Esri',
|
|
804
|
-
maxNativeZoom:
|
|
810
|
+
maxNativeZoom:10,
|
|
811
|
+
maxZoom:13
|
|
805
812
|
});
|
|
806
813
|
}
|
|
807
814
|
|
|
808
815
|
if (maplist.indexOf("EsriDG")!==-1) {
|
|
809
816
|
basemaps[layerlookup["EsriDG"]] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/{z}/{y}/{x}', {
|
|
810
817
|
attribution: 'Tiles © Esri — Esri, DeLorme, NAVTEQ',
|
|
811
|
-
maxNativeZoom:
|
|
818
|
+
maxNativeZoom:16,
|
|
819
|
+
maxZoom:18
|
|
812
820
|
});
|
|
813
821
|
}
|
|
814
822
|
|
|
@@ -1144,7 +1152,7 @@ var addOverlays = function(overlist) {
|
|
|
1144
1152
|
|
|
1145
1153
|
// Add the OpenSea markers layer
|
|
1146
1154
|
if (overlist.indexOf("SN")!==-1) {
|
|
1147
|
-
overlays["ship
|
|
1155
|
+
overlays["ship navigation"] = L.tileLayer('https://tiles.openseamap.org/seamark/{z}/{x}/{y}.png', {
|
|
1148
1156
|
maxZoom: 19,
|
|
1149
1157
|
attribution: 'Map data: © <a href="https://www.openseamap.org">OpenSeaMap</a> contributors'
|
|
1150
1158
|
});
|
|
@@ -1980,7 +1988,7 @@ function setMarker(data) {
|
|
|
1980
1988
|
else if (data.heading !== undefined) { track = data.heading; }
|
|
1981
1989
|
else if (data.bearing !== undefined) { track = data.bearing; }
|
|
1982
1990
|
if (track != undefined) { // if there is a heading
|
|
1983
|
-
if (data.speed != null &&
|
|
1991
|
+
if (data.speed != null && data.length === undefined) { // and a speed - lets convert to a leader length
|
|
1984
1992
|
data.length = parseFloat(data.speed || "0") * 60;
|
|
1985
1993
|
var re1 = new RegExp('kn|knot|kt','i');
|
|
1986
1994
|
var re2 = new RegExp('kph|kmh','i');
|
|
@@ -1989,7 +1997,7 @@ function setMarker(data) {
|
|
|
1989
1997
|
else if ( re2.test(""+data.speed) ) { data.length = data.length * 0.44704; }
|
|
1990
1998
|
else if ( re3.test(""+data.speed) ) { data.length = data.length * 0.277778; }
|
|
1991
1999
|
}
|
|
1992
|
-
if (data.length
|
|
2000
|
+
if (data.length !== undefined) {
|
|
1993
2001
|
if (polygons[data.name] != null && !polygons[data.name].hasOwnProperty("_layers")) {
|
|
1994
2002
|
map.removeLayer(polygons[data.name]);
|
|
1995
2003
|
}
|
|
@@ -2449,6 +2457,11 @@ function doCommand(cmd) {
|
|
|
2449
2457
|
else if (cmd.map.url.slice(-4).toLowerCase() === ".pbf") {
|
|
2450
2458
|
overlays[cmd.map.overlay] = VectorTileLayer(cmd.map.url, cmd.map.opt);
|
|
2451
2459
|
}
|
|
2460
|
+
else if (cmd.map.hasOwnProperty("transparentPixels")) {
|
|
2461
|
+
cmd.map.opt.pixelCodes = cmd.map.transparentPixels;
|
|
2462
|
+
cmd.map.opt.matchRGBA = [ 0,0,0,0 ];
|
|
2463
|
+
overlays[cmd.map.overlay] = L.tileLayerPixelFilter(cmd.map.url, cmd.map.opt);
|
|
2464
|
+
}
|
|
2452
2465
|
else {
|
|
2453
2466
|
overlays[cmd.map.overlay] = L.tileLayer(cmd.map.url, cmd.map.opt);
|
|
2454
2467
|
}
|
|
@@ -2563,6 +2576,7 @@ function doCommand(cmd) {
|
|
|
2563
2576
|
|
|
2564
2577
|
// handle any incoming GEOJSON directly - may style badly
|
|
2565
2578
|
function doGeojson(n,g,l,o) {
|
|
2579
|
+
//console.log("GEOJSON",n,g,l,o)
|
|
2566
2580
|
var lay = l || g.name || "unknown";
|
|
2567
2581
|
// if (!basemaps[lay]) {
|
|
2568
2582
|
var opt = { style: function(feature) {
|
|
@@ -2594,12 +2608,29 @@ function doGeojson(n,g,l,o) {
|
|
|
2594
2608
|
return st;
|
|
2595
2609
|
}}
|
|
2596
2610
|
opt.pointToLayer = function (feature, latlng) {
|
|
2597
|
-
var myMarker
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2611
|
+
var myMarker;
|
|
2612
|
+
if (feature.properties.hasOwnProperty("SIDC")) {
|
|
2613
|
+
myMarker = new ms.Symbol( feature.properties.SIDC.toUpperCase(), {
|
|
2614
|
+
uniqueDesignation:unescape(encodeURIComponent(feature.properties.title)) ,
|
|
2615
|
+
country:feature.properties.country,
|
|
2616
|
+
direction:feature.properties.bearing,
|
|
2617
|
+
additionalInformation:feature.properties.modifier,
|
|
2618
|
+
size:24
|
|
2619
|
+
});
|
|
2620
|
+
myMarker = L.icon({
|
|
2621
|
+
iconUrl: myMarker.toDataURL(),
|
|
2622
|
+
iconAnchor: [myMarker.getAnchor().x, myMarker.getAnchor().y],
|
|
2623
|
+
className: "natoicon",
|
|
2624
|
+
});
|
|
2625
|
+
}
|
|
2626
|
+
else {
|
|
2627
|
+
myMarker = L.VectorMarkers.icon({
|
|
2628
|
+
icon: feature.properties["marker-symbol"] || "circle",
|
|
2629
|
+
markerColor: (feature.properties["marker-color"] || "#910000"),
|
|
2630
|
+
prefix: 'fa',
|
|
2631
|
+
iconColor: 'white'
|
|
2632
|
+
});
|
|
2633
|
+
}
|
|
2603
2634
|
if (!feature.properties.hasOwnProperty("title")) {
|
|
2604
2635
|
feature.properties.title = feature.properties["marker-symbol"];
|
|
2605
2636
|
}
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
<script src="leaflet/Leaflet.Coordinates.js"></script>
|
|
43
43
|
<script src="leaflet/leaflet.latlng-graticule.js"></script>
|
|
44
44
|
<script src="leaflet/Semicircle.js"></script>
|
|
45
|
+
<script src="leaflet/L.TileLayer.PixelFilter.js"></script>
|
|
45
46
|
<script src="leaflet/dialog-polyfill.js"></script>
|
|
46
47
|
|
|
47
48
|
<script src="images/emoji.js"></script>
|
package/worldmap.html
CHANGED
|
@@ -293,7 +293,7 @@ If <i>Web Path</i> is left empty, then by default <code>⌘⇧m</code> - <code>c
|
|
|
293
293
|
<p>Icons of type <i>plane</i>, <i>ship</i>, <i>car</i>, <i>uav</i> or <i>arrow</i> will use built in SVG icons that align to the
|
|
294
294
|
<code>bearing</code> value.</p>
|
|
295
295
|
<p>Font Awesome (<a href="https://fontawesome.com/v4.7.0/icons/" target="_new">fa-icons 4.7</a>) can also be used, as can
|
|
296
|
-
NATO symbology codes (SIDC), or <a href="https://github.com/dceejay/RedMap/blob/master/emojilist.md" target="_new">:emoji name:</a>,
|
|
296
|
+
NATO symbology codes (<a href="https://spatialillusions.com/unitgenerator/">SIDC</a>), or <a href="https://github.com/dceejay/RedMap/blob/master/emojilist.md" target="_new">:emoji name:</a>,
|
|
297
297
|
or the url of a small icon image (32x32)</p>
|
|
298
298
|
<p>See the <a href="https://www.npmjs.com/package/node-red-contrib-web-worldmap" target="_new">README</a> for further
|
|
299
299
|
details and examples of icons and commands for drawing <b>lines</b> and <b>areas</b>, and to <b>add layers</b> and
|
|
@@ -437,7 +437,7 @@ If <i>Web Path</i> is left empty, then by default <code>⌘⇧m</code> - <code>c
|
|
|
437
437
|
}
|
|
438
438
|
});
|
|
439
439
|
|
|
440
|
-
$.get('
|
|
440
|
+
$.get('/-ui-worldmap', function (data) {
|
|
441
441
|
if (data === "true") {
|
|
442
442
|
RED.nodes.registerType('ui_worldmap',{
|
|
443
443
|
category: 'dashboard',
|
package/worldmap.js
CHANGED
|
@@ -521,7 +521,7 @@ module.exports = function(RED) {
|
|
|
521
521
|
}
|
|
522
522
|
RED.nodes.registerType("worldmap-hull",WorldMapHull);
|
|
523
523
|
|
|
524
|
-
RED.httpNode.get("
|
|
524
|
+
RED.httpNode.get("/-ui-worldmap", function(req, res) {
|
|
525
525
|
res.send(ui ? "true": "false");
|
|
526
526
|
});
|
|
527
527
|
}
|