node-red-contrib-web-worldmap 5.5.8 → 5.6.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 +2 -0
- package/README.md +4 -6
- package/package.json +1 -1
- package/worldmap/worldmap.js +59 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
### Change Log for Node-RED Worldmap
|
|
2
2
|
|
|
3
|
+
- v5.6.1 - Also call autoswitch on initial connect to ensure map in view.
|
|
4
|
+
- v5.6.0 - Autoswitch pmtiles basemaps based on zoom and/or coverage.
|
|
3
5
|
- v5.5.8 - Bump qs dep for CVE
|
|
4
6
|
- v5.5.7 - Fix COG handling for built in icons, bump various libs for CVEs
|
|
5
7
|
- v5.5.4 - slight tweak to geojson property display as table
|
package/README.md
CHANGED
|
@@ -10,6 +10,8 @@ A <a href="https://nodered.org" target="mapinfo">Node-RED</a> node to provide a
|
|
|
10
10
|
|
|
11
11
|
### Updates
|
|
12
12
|
|
|
13
|
+
- v5.6.1 - Also call autoswitch on initial connect to ensure map in view.
|
|
14
|
+
- v5.6.0 - Autoswitch pmtiles basemaps based on zoom and/or coverage.
|
|
13
15
|
- v5.5.8 - Bump qs dep for CVE
|
|
14
16
|
- v5.5.7 - Fix COG handling for built in icons, bump various libs for CVEs
|
|
15
17
|
- v5.5.4 - slight tweak to geojson property display as table
|
|
@@ -20,12 +22,6 @@ A <a href="https://nodered.org" target="mapinfo">Node-RED</a> node to provide a
|
|
|
20
22
|
- v5.4.0 - Let msg.payload.command.zoomLevels set an array of acceptable zoom levels. Issue #312
|
|
21
23
|
- v5.3.0 - Let msg.payload.popupOptions object set Leaflet popup options so it can be customised. Issue #311
|
|
22
24
|
- v5.2.0 - Allow left click send back co-ords. Let Button be replaceable more easily and take value property. Issue #308 and #309
|
|
23
|
-
- v5.1.6 - Let Cot __milsym set the SIDC if present.
|
|
24
|
-
- v5.1.5 - Fix links to SIDC unitgenerator so it is now local.
|
|
25
|
-
- v5.1.4 - Fix clearlayer for tracks node.
|
|
26
|
-
- v5.1.2 - Fix for longer line msg properties.
|
|
27
|
-
- v5.1.1 - Fix CoT inline image.
|
|
28
|
-
- v5.1.0 - Let special icons be sizeable using iconSize property.
|
|
29
25
|
|
|
30
26
|
- see [CHANGELOG](https://github.com/dceejay/RedMap/blob/master/CHANGELOG.md) for full list of changes.
|
|
31
27
|
|
|
@@ -767,6 +763,8 @@ You can also load them dynamically with a command like
|
|
|
767
763
|
|
|
768
764
|
Where `opt` can be as per the options file mentioned above - or omitted completely.
|
|
769
765
|
|
|
766
|
+
If you have multiple pmtiles loaded then the map will try to autoswitch if you move out of bounds of one and into another - or zoom in or out beyond the zoom limits and there is another suitable pmtiles file available.
|
|
767
|
+
|
|
770
768
|
NOTE: for some reason many files converted to pmtiles format fail to load/display. In this case you can easily use the tileserver-gl map server either natively or via docker (see below) to serve the pmtiles format file.
|
|
771
769
|
|
|
772
770
|
### Using a Docker Map Server
|
package/package.json
CHANGED
package/worldmap/worldmap.js
CHANGED
|
@@ -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 = " © DCJ
|
|
21
|
+
var pagefoot = " © DCJ 2026";
|
|
22
22
|
var inIframe = false;
|
|
23
23
|
var showUserMenu = true;
|
|
24
24
|
var showLayerMenu = true;
|
|
@@ -94,7 +94,7 @@ var connect = function() {
|
|
|
94
94
|
document.getElementById("footer").innerHTML = "<font color='#494'>"+pagefoot+"</font>";
|
|
95
95
|
}
|
|
96
96
|
ws.send(JSON.stringify({action:"connected",parameters:Object.fromEntries((new URL(location)).searchParams),clientTimezone:Intl.DateTimeFormat().resolvedOptions().timeZone || false}));
|
|
97
|
-
setTimeout(function() { onoffline(); }, 500);
|
|
97
|
+
setTimeout(function() { onoffline(); pickMapLayer();}, 500);
|
|
98
98
|
};
|
|
99
99
|
ws.onclose = function() {
|
|
100
100
|
console.log("DISCONNECTED");
|
|
@@ -862,6 +862,61 @@ function showMapCurrentZoom() {
|
|
|
862
862
|
},750);
|
|
863
863
|
}
|
|
864
864
|
|
|
865
|
+
function pickMapLayer() {
|
|
866
|
+
// if we have bounds meta data for the current baselayer (usually pmtiles)
|
|
867
|
+
if (basemaps[baselayername] && basemaps[baselayername].hasOwnProperty("meta")) {
|
|
868
|
+
const m = basemaps[baselayername].meta
|
|
869
|
+
const c = map.getCenter()
|
|
870
|
+
const z = map.getZoom();
|
|
871
|
+
//console.log("ZOOM: "+m.minZoom+" - "+z+" - "+m.maxZoom)
|
|
872
|
+
// if we are within the meta bounds and we have zoomed in beyond the max zoom level for this baselayer, try to find a more suitable baselayer
|
|
873
|
+
if (c.lat > m.minLat && c.lat < m.maxLat && c.lng > m.minLon && c.lng < m.maxLon) {
|
|
874
|
+
if (z > m.maxZoom) {
|
|
875
|
+
for (var key in basemaps) {
|
|
876
|
+
if (key !== baselayername && basemaps[key].hasOwnProperty("meta")) {
|
|
877
|
+
const mb = basemaps[key].meta;
|
|
878
|
+
if (z <= mb.maxZoom && c.lat > mb.minLat && c.lat < mb.maxLat && c.lng > mb.minLon && c.lng < mb.maxLon) {
|
|
879
|
+
console.log("Zoom greater than "+m.maxZoom+", Switching to "+key);
|
|
880
|
+
map.removeLayer(basemaps[baselayername]);
|
|
881
|
+
baselayername = key;
|
|
882
|
+
map.addLayer(basemaps[baselayername]);
|
|
883
|
+
break;
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
else if (z <= m.minZoom) {
|
|
889
|
+
for (var key in basemaps) {
|
|
890
|
+
if (key !== baselayername && basemaps[key].hasOwnProperty("meta")) {
|
|
891
|
+
if (z >= basemaps[key].meta.minZoom) {
|
|
892
|
+
console.log("Zoom below min "+m.minZoom+", Switching to "+key);
|
|
893
|
+
map.removeLayer(basemaps[baselayername]);
|
|
894
|
+
baselayername = key;
|
|
895
|
+
map.addLayer(basemaps[baselayername]);
|
|
896
|
+
break;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
// if we are outside the meta bounds, try to find a baselayer that does cover this area
|
|
903
|
+
else {
|
|
904
|
+
for (var key in basemaps) {
|
|
905
|
+
if (basemaps[key].hasOwnProperty("meta") && key !== baselayername) {
|
|
906
|
+
const mb = basemaps[key].meta;
|
|
907
|
+
if (c.lat > mb.minLat && c.lat < mb.maxLat && c.lng > mb.minLon && c.lng < mb.maxLon) {
|
|
908
|
+
console.log("Outside Bounds, Switching to "+key);
|
|
909
|
+
map.removeLayer(basemaps[baselayername]);
|
|
910
|
+
baselayername = key;
|
|
911
|
+
map.addLayer(basemaps[baselayername]);
|
|
912
|
+
break;
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
|
|
865
920
|
map.on('zoomend', function() {
|
|
866
921
|
showMapCurrentZoom();
|
|
867
922
|
window.localStorage.setItem("lastzoom", map.getZoom());
|
|
@@ -878,6 +933,7 @@ map.on('moveend', function() {
|
|
|
878
933
|
oldBounds = {sw:{lat:b._southWest.lat,lng:b._southWest.lng},ne:{lat:b._northEast.lat,lng:b._northEast.lng}};
|
|
879
934
|
}
|
|
880
935
|
edgeAware();
|
|
936
|
+
pickMapLayer();
|
|
881
937
|
});
|
|
882
938
|
map.on('locationfound', onLocationFound);
|
|
883
939
|
map.on('locationerror', onLocationError);
|
|
@@ -2754,6 +2810,7 @@ function doCommand(cmd) {
|
|
|
2754
2810
|
else {
|
|
2755
2811
|
basemaps[cmd.map.name] = pmtiles.leafletRasterLayer(p, opt);
|
|
2756
2812
|
}
|
|
2813
|
+
basemaps[cmd.map.name].meta = { minZoom: h.minZoom, maxZoom: h.maxZoom, minLat: h.minLat, maxLat: h.maxLat, minLon: h.minLon, maxLon: h.maxLon };
|
|
2757
2814
|
if (!existsalready) {
|
|
2758
2815
|
layercontrol.addBaseLayer(basemaps[cmd.map.name],cmd.map.name);
|
|
2759
2816
|
}
|