node-red-contrib-web-worldmap 5.5.8 → 5.6.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 +1 -0
- package/README.md +3 -0
- package/package.json +1 -1
- package/worldmap/worldmap.js +55 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
### Change Log for Node-RED Worldmap
|
|
2
2
|
|
|
3
|
+
- v5.6.0 - Autoswitch pmtiles basemaps based on zoom and/or coverage.
|
|
3
4
|
- v5.5.8 - Bump qs dep for CVE
|
|
4
5
|
- v5.5.7 - Fix COG handling for built in icons, bump various libs for CVEs
|
|
5
6
|
- v5.5.4 - slight tweak to geojson property display as table
|
package/README.md
CHANGED
|
@@ -10,6 +10,7 @@ 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.0 - Autoswitch pmtiles basemaps based on zoom and/or coverage.
|
|
13
14
|
- v5.5.8 - Bump qs dep for CVE
|
|
14
15
|
- v5.5.7 - Fix COG handling for built in icons, bump various libs for CVEs
|
|
15
16
|
- v5.5.4 - slight tweak to geojson property display as table
|
|
@@ -767,6 +768,8 @@ You can also load them dynamically with a command like
|
|
|
767
768
|
|
|
768
769
|
Where `opt` can be as per the options file mentioned above - or omitted completely.
|
|
769
770
|
|
|
771
|
+
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.
|
|
772
|
+
|
|
770
773
|
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
774
|
|
|
772
775
|
### 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;
|
|
@@ -878,6 +878,59 @@ map.on('moveend', function() {
|
|
|
878
878
|
oldBounds = {sw:{lat:b._southWest.lat,lng:b._southWest.lng},ne:{lat:b._northEast.lat,lng:b._northEast.lng}};
|
|
879
879
|
}
|
|
880
880
|
edgeAware();
|
|
881
|
+
|
|
882
|
+
// if we have bounds meta data for the current baselayer (usually pmtiles)
|
|
883
|
+
if (basemaps[baselayername] && basemaps[baselayername].hasOwnProperty("meta")) {
|
|
884
|
+
const m = basemaps[baselayername].meta
|
|
885
|
+
const c = map.getCenter()
|
|
886
|
+
const z = map.getZoom();
|
|
887
|
+
//console.log("ZOOM: "+m.minZoom+" - "+z+" - "+m.maxZoom)
|
|
888
|
+
// 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
|
|
889
|
+
if (c.lat > m.minLat && c.lat < m.maxLat && c.lng > m.minLon && c.lng < m.maxLon) {
|
|
890
|
+
if (z > m.maxZoom) {
|
|
891
|
+
for (var key in basemaps) {
|
|
892
|
+
if (key !== baselayername && basemaps[key].hasOwnProperty("meta")) {
|
|
893
|
+
const mb = basemaps[key].meta;
|
|
894
|
+
if (z <= mb.maxZoom && c.lat > mb.minLat && c.lat < mb.maxLat && c.lng > mb.minLon && c.lng < mb.maxLon) {
|
|
895
|
+
console.log("Zoom greater than "+m.maxZoom+", Switching to "+key);
|
|
896
|
+
map.removeLayer(basemaps[baselayername]);
|
|
897
|
+
baselayername = key;
|
|
898
|
+
map.addLayer(basemaps[baselayername]);
|
|
899
|
+
break;
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
else if (z <= m.minZoom) {
|
|
905
|
+
for (var key in basemaps) {
|
|
906
|
+
if (key !== baselayername && basemaps[key].hasOwnProperty("meta")) {
|
|
907
|
+
if (z >= basemaps[key].meta.minZoom) {
|
|
908
|
+
console.log("Zoom below min "+m.minZoom+", Switching to "+key);
|
|
909
|
+
map.removeLayer(basemaps[baselayername]);
|
|
910
|
+
baselayername = key;
|
|
911
|
+
map.addLayer(basemaps[baselayername]);
|
|
912
|
+
break;
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
// if we are outside the meta bounds, try to find a baselayer that does cover this area
|
|
919
|
+
else {
|
|
920
|
+
for (var key in basemaps) {
|
|
921
|
+
if (basemaps[key].hasOwnProperty("meta") && key !== baselayername) {
|
|
922
|
+
const mb = basemaps[key].meta;
|
|
923
|
+
if (c.lat > mb.minLat && c.lat < mb.maxLat && c.lng > mb.minLon && c.lng < mb.maxLon) {
|
|
924
|
+
console.log("Outside Bounds, Switching to "+key);
|
|
925
|
+
map.removeLayer(basemaps[baselayername]);
|
|
926
|
+
baselayername = key;
|
|
927
|
+
map.addLayer(basemaps[baselayername]);
|
|
928
|
+
break;
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
}
|
|
881
934
|
});
|
|
882
935
|
map.on('locationfound', onLocationFound);
|
|
883
936
|
map.on('locationerror', onLocationError);
|
|
@@ -2754,6 +2807,7 @@ function doCommand(cmd) {
|
|
|
2754
2807
|
else {
|
|
2755
2808
|
basemaps[cmd.map.name] = pmtiles.leafletRasterLayer(p, opt);
|
|
2756
2809
|
}
|
|
2810
|
+
basemaps[cmd.map.name].meta = { minZoom: h.minZoom, maxZoom: h.maxZoom, minLat: h.minLat, maxLat: h.maxLat, minLon: h.minLon, maxLon: h.maxLon };
|
|
2757
2811
|
if (!existsalready) {
|
|
2758
2812
|
layercontrol.addBaseLayer(basemaps[cmd.map.name],cmd.map.name);
|
|
2759
2813
|
}
|