node-red-contrib-web-worldmap 2.34.0 → 2.36.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 +2 -0
- package/README.md +3 -0
- package/package.json +1 -1
- package/worldmap/worldmap.js +74 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
### Change Log for Node-RED Worldmap
|
|
2
2
|
|
|
3
|
+
- v2.36.0 - Add edge icons for SIDC markers just off the map.
|
|
4
|
+
- v2.35.0 - Let clickable:false work for markers as well.
|
|
3
5
|
- v2.34.0 - Let icon "url" be a local fixed path (PR #223)
|
|
4
6
|
- v2.33.0 - Let shapes create click event. (from PR #221)
|
|
5
7
|
Fix heatmap delete point bug. Issue #222
|
package/README.md
CHANGED
|
@@ -11,6 +11,8 @@ map web page for plotting "things" on.
|
|
|
11
11
|
|
|
12
12
|
### Updates
|
|
13
13
|
|
|
14
|
+
- v2.36.0 - Add edge icons for SIDC markers just off the map.
|
|
15
|
+
- v2.35.0 - Let clickable:false work for markers as well.
|
|
14
16
|
- v2.34.0 - Let icon "url" be a local fixed path (PR #223)
|
|
15
17
|
- v2.33.0 - Let shapes create click event. (from PR #221)
|
|
16
18
|
Fix heatmap delete point bug. Issue #222
|
|
@@ -67,6 +69,7 @@ Optional properties include
|
|
|
67
69
|
- **weblink** : adds a link to an external page. Either set a url as a *string*, or an *object* like `{"name":"BBC News", "url":"https://news.bbc.co.uk", "target":"_new"}`, or multiple links with an *array of objects* `[{"name":"BBC News", "url":"https://news.bbc.co.uk", "target":"_new"},{"name":"node-red", "url":"https://nodered.org", "target":"_new"}]`
|
|
68
70
|
- **addtoheatmap** : set to <i>false</i> to exclude point from contributing to the heatmap layer. (default true)
|
|
69
71
|
- **intensity** : set to a value of 0.1 - 1.0 to set the intensity of the point on the heatmap layer. (default 1.0)
|
|
72
|
+
- **clickable** : Default true. Setting to false disables showing any popup.
|
|
70
73
|
- **popped** : set to true to automatically open the popup info box, set to false to close it.
|
|
71
74
|
- **popup** : html to fill the popup if you don't want the automatic default of the properties list. Using this overrides photourl, videourl and weblink options.
|
|
72
75
|
- **label** : displays the contents as a permanent label next to the marker, or
|
package/package.json
CHANGED
package/worldmap/worldmap.js
CHANGED
|
@@ -33,7 +33,9 @@ var drawingColour = "#910000";
|
|
|
33
33
|
var sendDrawing;
|
|
34
34
|
var colorControl;
|
|
35
35
|
var sendRoute;
|
|
36
|
-
var oldBounds = {ne:{lat:0,lng:0},sw:{lat:0,lng:0}};
|
|
36
|
+
var oldBounds = {ne:{lat:0, lng:0}, sw:{lat:0, lng:0}};
|
|
37
|
+
var edgeLayer = new L.layerGroup();
|
|
38
|
+
var edgeEnabled = true;
|
|
37
39
|
|
|
38
40
|
var iconSz = {
|
|
39
41
|
"Team/Crew": 24,
|
|
@@ -371,6 +373,69 @@ var Lgrid = L.latlngGraticule({
|
|
|
371
373
|
]
|
|
372
374
|
});
|
|
373
375
|
|
|
376
|
+
// Add small sidc icons around edge of map for things just outside of view
|
|
377
|
+
// This function based heavily on Game Aware code from Måns Beckman
|
|
378
|
+
// Copyright (c) 2013 Måns Beckman, All rights reserved.
|
|
379
|
+
var edgeAware = function() {
|
|
380
|
+
if (!edgeEnabled) { return; }
|
|
381
|
+
map.removeLayer(edgeLayer)
|
|
382
|
+
edgeLayer = new L.layerGroup();
|
|
383
|
+
var mapBounds = map.getBounds();
|
|
384
|
+
var mapBoundsCenter = mapBounds.getCenter();
|
|
385
|
+
|
|
386
|
+
pSW = map.options.crs.latLngToPoint(mapBounds.getSouthWest(), map.getZoom());
|
|
387
|
+
pNE = map.options.crs.latLngToPoint(mapBounds.getNorthEast(), map.getZoom());
|
|
388
|
+
pCenter = map.options.crs.latLngToPoint(mapBoundsCenter, map.getZoom());
|
|
389
|
+
|
|
390
|
+
var viewBounds = L.latLngBounds(map.options.crs.pointToLatLng(L.point(pSW.x - (pCenter.x - pSW.x ), pSW.y - (pCenter.y - pSW.y )), map.getZoom()) , map.options.crs.pointToLatLng(L.point(pNE.x + (pNE.x - pCenter.x) , pNE.y + (pNE.y - pCenter.y) ), map.getZoom()) );
|
|
391
|
+
for (var id in markers) {
|
|
392
|
+
if (allData[id].hasOwnProperty("SIDC")) {
|
|
393
|
+
markerLatLng = markers[id].getLatLng();
|
|
394
|
+
if ( viewBounds.contains(markerLatLng) && !mapBounds.contains(markerLatLng) ) {
|
|
395
|
+
var k = (markerLatLng.lat - mapBoundsCenter.lat) / (markerLatLng.lng - mapBoundsCenter.lng);
|
|
396
|
+
|
|
397
|
+
if (markerLatLng.lng > mapBoundsCenter.lng) { x = mapBounds.getEast() - mapBoundsCenter.lng; }
|
|
398
|
+
else { x = (mapBounds.getWest() - mapBoundsCenter.lng); }
|
|
399
|
+
|
|
400
|
+
if (markerLatLng.lat < mapBoundsCenter.lat) { y = mapBounds.getSouth() - mapBoundsCenter.lat; }
|
|
401
|
+
else { y = mapBounds.getNorth() - mapBoundsCenter.lat; }
|
|
402
|
+
|
|
403
|
+
var lat = (mapBoundsCenter.lat + (k * x));
|
|
404
|
+
var lng = (mapBoundsCenter.lng + (y / k));
|
|
405
|
+
var iconAnchor = {x:5, y:5}
|
|
406
|
+
|
|
407
|
+
if (lng > mapBounds.getEast()) {
|
|
408
|
+
lng = mapBounds.getEast();
|
|
409
|
+
iconAnchor.x = 20;
|
|
410
|
+
}
|
|
411
|
+
if (lng < mapBounds.getWest()) {
|
|
412
|
+
lng = mapBounds.getWest();
|
|
413
|
+
iconAnchor.x = -5;
|
|
414
|
+
};
|
|
415
|
+
if (lat < mapBounds.getSouth()) {
|
|
416
|
+
lat = mapBounds.getSouth();
|
|
417
|
+
iconAnchor.y = 15;
|
|
418
|
+
}
|
|
419
|
+
if (lat > mapBounds.getNorth()) {
|
|
420
|
+
lat = mapBounds.getNorth();
|
|
421
|
+
iconAnchor.y = -5;
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
var eico = new ms.Symbol(allData[id].SIDC.substr(0,5)+"-------",{size:9});
|
|
425
|
+
var myicon = L.icon({
|
|
426
|
+
iconUrl: eico.toDataURL(),
|
|
427
|
+
iconAnchor: new L.Point(iconAnchor.x, iconAnchor.y),
|
|
428
|
+
className: "natoicon-s",
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
edgeLayer.addLayer(L.marker([lat,lng],{icon:myicon}))
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
edgeLayer.addTo(map)
|
|
436
|
+
}
|
|
437
|
+
// end of edge function
|
|
438
|
+
|
|
374
439
|
var panit = false;
|
|
375
440
|
function doPanit(v) {
|
|
376
441
|
if (v !== undefined) { panit = v; }
|
|
@@ -672,6 +737,7 @@ map.on('zoomend', function() {
|
|
|
672
737
|
var b = map.getBounds();
|
|
673
738
|
oldBounds = {sw:{lat:b._southWest.lat,lng:b._southWest.lng},ne:{lat:b._northEast.lat,lng:b._northEast.lng}};
|
|
674
739
|
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() }));
|
|
740
|
+
edgeAware();
|
|
675
741
|
});
|
|
676
742
|
map.on('moveend', function() {
|
|
677
743
|
window.localStorage.setItem("lastpos",JSON.stringify(map.getCenter()));
|
|
@@ -680,6 +746,7 @@ map.on('moveend', function() {
|
|
|
680
746
|
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() }));
|
|
681
747
|
oldBounds = {sw:{lat:b._southWest.lat,lng:b._southWest.lng},ne:{lat:b._northEast.lat,lng:b._northEast.lng}};
|
|
682
748
|
}
|
|
749
|
+
edgeAware();
|
|
683
750
|
});
|
|
684
751
|
map.on('locationfound', onLocationFound);
|
|
685
752
|
map.on('locationerror', onLocationError);
|
|
@@ -1871,6 +1938,7 @@ function setMarker(data) {
|
|
|
1871
1938
|
className: "natoicon",
|
|
1872
1939
|
});
|
|
1873
1940
|
marker = L.marker(ll, { title:data.name, icon:myicon, draggable:drag });
|
|
1941
|
+
edgeAware();
|
|
1874
1942
|
}
|
|
1875
1943
|
else {
|
|
1876
1944
|
myMarker = L.VectorMarkers.icon({
|
|
@@ -2024,12 +2092,11 @@ function setMarker(data) {
|
|
|
2024
2092
|
if (data.fill) { delete data.fill; }
|
|
2025
2093
|
if (data.draggable) { delete data.draggable; }
|
|
2026
2094
|
//if (!isNaN(data.speed)) { data.speed = data.speed.toFixed(2); }
|
|
2027
|
-
if (data.hasOwnProperty("clickable")) { delete data.clickable; }
|
|
2028
2095
|
if (data.hasOwnProperty("fillColor")) { delete data.fillColor; }
|
|
2029
2096
|
if (data.hasOwnProperty("radius")) { delete data.radius; }
|
|
2030
2097
|
if (data.hasOwnProperty("greatcircle")) { delete data.greatcircle; }
|
|
2031
2098
|
for (var i in data) {
|
|
2032
|
-
if ((i != "name") && (i != "length")) {
|
|
2099
|
+
if ((i != "name") && (i != "length") && (i != "clickable")) {
|
|
2033
2100
|
if (typeof data[i] === "object") {
|
|
2034
2101
|
words += i +" : "+JSON.stringify(data[i])+"<br/>";
|
|
2035
2102
|
} else {
|
|
@@ -2042,8 +2109,10 @@ function setMarker(data) {
|
|
|
2042
2109
|
words = "<b>"+data.name+"</b><br/>" + words; //"<button style=\"border-radius:4px; float:right; background-color:lightgrey;\" onclick='popped=false;popmark.closePopup();'>X</button><br/>" + words;
|
|
2043
2110
|
var wopt = {autoClose:false, closeButton:true, closeOnClick:false, minWidth:200};
|
|
2044
2111
|
if (words.indexOf('<video ') >=0 || words.indexOf('<img ') >=0 ) { wopt.maxWidth="640"; }
|
|
2045
|
-
|
|
2046
|
-
|
|
2112
|
+
if (!data.hasOwnProperty("clickable") && data.clickable != false) {
|
|
2113
|
+
marker.bindPopup(words, wopt);
|
|
2114
|
+
marker._popup.dname = data.name;
|
|
2115
|
+
}
|
|
2047
2116
|
marker.lay = lay; // and the layer it is on
|
|
2048
2117
|
|
|
2049
2118
|
// marker.on('click', function(e) {
|