Skip to content

Commit bbb2314

Browse files
committed
Also call autoswitch on initial connect to ensure map in view.
1 parent df5a420 commit bbb2314

File tree

4 files changed

+24
-25
lines changed

4 files changed

+24
-25
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
### Change Log for Node-RED Worldmap
22

3+
- v5.6.1 - Also call autoswitch on initial connect to ensure map in view.
34
- v5.6.0 - Autoswitch pmtiles basemaps based on zoom and/or coverage.
45
- v5.5.8 - Bump qs dep for CVE
56
- v5.5.7 - Fix COG handling for built in icons, bump various libs for CVEs

README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ A <a href="https://nodered.org" target="mapinfo">Node-RED</a> node to provide a
1010

1111
### Updates
1212

13+
- v5.6.1 - Also call autoswitch on initial connect to ensure map in view.
1314
- v5.6.0 - Autoswitch pmtiles basemaps based on zoom and/or coverage.
1415
- v5.5.8 - Bump qs dep for CVE
1516
- v5.5.7 - Fix COG handling for built in icons, bump various libs for CVEs
@@ -21,12 +22,6 @@ A <a href="https://nodered.org" target="mapinfo">Node-RED</a> node to provide a
2122
- v5.4.0 - Let msg.payload.command.zoomLevels set an array of acceptable zoom levels. Issue #312
2223
- v5.3.0 - Let msg.payload.popupOptions object set Leaflet popup options so it can be customised. Issue #311
2324
- v5.2.0 - Allow left click send back co-ords. Let Button be replaceable more easily and take value property. Issue #308 and #309
24-
- v5.1.6 - Let Cot __milsym set the SIDC if present.
25-
- v5.1.5 - Fix links to SIDC unitgenerator so it is now local.
26-
- v5.1.4 - Fix clearlayer for tracks node.
27-
- v5.1.2 - Fix for longer line msg properties.
28-
- v5.1.1 - Fix CoT inline image.
29-
- v5.1.0 - Let special icons be sizeable using iconSize property.
3025

3126
- see [CHANGELOG](https://github.com/dceejay/RedMap/blob/master/CHANGELOG.md) for full list of changes.
3227

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-red-contrib-web-worldmap",
3-
"version": "5.6.0",
3+
"version": "5.6.1",
44
"description": "A Node-RED node to provide a web page of a world map for plotting things on.",
55
"dependencies": {
66
"@turf/bezier-spline": "~7.3.4",

worldmap/worldmap.js

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ var connect = function() {
9494
document.getElementById("footer").innerHTML = "<font color='#494'>"+pagefoot+"</font>";
9595
}
9696
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);
9898
};
9999
ws.onclose = function() {
100100
console.log("DISCONNECTED");
@@ -862,23 +862,7 @@ function showMapCurrentZoom() {
862862
},750);
863863
}
864864

865-
map.on('zoomend', function() {
866-
showMapCurrentZoom();
867-
window.localStorage.setItem("lastzoom", map.getZoom());
868-
var b = map.getBounds();
869-
oldBounds = {sw:{lat:b._southWest.lat,lng:b._southWest.lng},ne:{lat:b._northEast.lat,lng:b._northEast.lng}};
870-
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() }));
871-
edgeAware();
872-
});
873-
map.on('moveend', function() {
874-
window.localStorage.setItem("lastpos",JSON.stringify(map.getCenter()));
875-
var b = map.getBounds();
876-
if (b._southWest.lat !== oldBounds.sw.lat && b._southWest.lng !== oldBounds.sw.lng && b._northEast.lat !== oldBounds.ne.lat && b._northEast.lng !== oldBounds.ne.lng) {
877-
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() }));
878-
oldBounds = {sw:{lat:b._southWest.lat,lng:b._southWest.lng},ne:{lat:b._northEast.lat,lng:b._northEast.lng}};
879-
}
880-
edgeAware();
881-
865+
function pickMapLayer() {
882866
// if we have bounds meta data for the current baselayer (usually pmtiles)
883867
if (basemaps[baselayername] && basemaps[baselayername].hasOwnProperty("meta")) {
884868
const m = basemaps[baselayername].meta
@@ -931,6 +915,25 @@ map.on('moveend', function() {
931915
}
932916
}
933917
}
918+
}
919+
920+
map.on('zoomend', function() {
921+
showMapCurrentZoom();
922+
window.localStorage.setItem("lastzoom", map.getZoom());
923+
var b = map.getBounds();
924+
oldBounds = {sw:{lat:b._southWest.lat,lng:b._southWest.lng},ne:{lat:b._northEast.lat,lng:b._northEast.lng}};
925+
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() }));
926+
edgeAware();
927+
});
928+
map.on('moveend', function() {
929+
window.localStorage.setItem("lastpos",JSON.stringify(map.getCenter()));
930+
var b = map.getBounds();
931+
if (b._southWest.lat !== oldBounds.sw.lat && b._southWest.lng !== oldBounds.sw.lng && b._northEast.lat !== oldBounds.ne.lat && b._northEast.lng !== oldBounds.ne.lng) {
932+
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() }));
933+
oldBounds = {sw:{lat:b._southWest.lat,lng:b._southWest.lng},ne:{lat:b._northEast.lat,lng:b._northEast.lng}};
934+
}
935+
edgeAware();
936+
pickMapLayer();
934937
});
935938
map.on('locationfound', onLocationFound);
936939
map.on('locationerror', onLocationError);

0 commit comments

Comments
 (0)