add zoom to bounds, fix max zoom on layers

This commit is contained in:
Dave Conway-Jones 2021-11-03 21:28:22 +00:00
parent c3d2ae42b9
commit 4fb075d28c
No known key found for this signature in database
GPG Key ID: 88BA2B8A411BE9FF
4 changed files with 15 additions and 10 deletions

View File

@ -1,6 +1,7 @@
### Change Log for Node-RED Worldmap ### Change Log for Node-RED Worldmap
- v2.21.2 - expand ship nav to ship navigation. - v2.21.3 - Add zoom to bounds action. Adjust map layers max zoom levels.
- v2.21.2 - Expand ship nav to ship navigation.
- v2.21.1 - Fix ui check callback to not use . - v2.21.1 - Fix ui check callback to not use .
- v2.21.0 - Let config panel select maps to show, default map and choice of overlays. - v2.21.0 - Let config panel select maps to show, default map and choice of overlays.
- v2.20.0 - Add support of .pbf map layers. Issue #123. - v2.20.0 - Add support of .pbf map layers. Issue #123.

View File

@ -11,7 +11,8 @@ map web page for plotting "things" on.
### Updates ### Updates
- v2.21.2 - expand ship nav to ship navigation. - v2.21.3 - Add zoom to bounds action. Adjust map layers max zoom levels.
- v2.21.2 - Expand ship nav to ship navigation.
- v2.21.1 - Fix ui check callback to not use . - v2.21.1 - Fix ui check callback to not use .
- v2.21.0 - Let config panel select maps to show, default map and choice of overlays. - v2.21.0 - Let config panel select maps to show, default map and choice of overlays.
- v2.20.0 - Add support of .pbf map layers. Issue 123. - v2.20.0 - Add support of .pbf map layers. Issue 123.

View File

@ -1,6 +1,6 @@
{ {
"name": "node-red-contrib-web-worldmap", "name": "node-red-contrib-web-worldmap",
"version": "2.21.2", "version": "2.21.3",
"description": "A Node-RED node to provide a web page of a world map for plotting things on.", "description": "A Node-RED node to provide a web page of a world map for plotting things on.",
"dependencies": { "dependencies": {
"@turf/bezier-spline": "~6.5.0", "@turf/bezier-spline": "~6.5.0",

View File

@ -593,7 +593,7 @@ map.on('baselayerchange', function(e) {
}); });
function showMapCurrentZoom() { function showMapCurrentZoom() {
//console.log("zoom:",map.getZoom()); //console.log("ZOOM:",map.getZoom());
for (var l in layers) { for (var l in layers) {
if (layers[l].hasOwnProperty("_zoom")) { if (layers[l].hasOwnProperty("_zoom")) {
if (map.getZoom() >= clusterAt) { if (map.getZoom() >= clusterAt) {
@ -635,12 +635,12 @@ map.on('zoomend', function() {
showMapCurrentZoom(); showMapCurrentZoom();
window.localStorage.setItem("lastzoom", map.getZoom()); window.localStorage.setItem("lastzoom", map.getZoom());
var b = map.getBounds(); var b = map.getBounds();
ws.send(JSON.stringify({action:"bounds", south:b._southWest.lat, west:b._southWest.lng, north:b._northEast.lat, east:b._northEast.lng })); 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() }));
}); });
map.on('moveend', function() { map.on('moveend', function() {
window.localStorage.setItem("lastpos",JSON.stringify(map.getCenter())); window.localStorage.setItem("lastpos",JSON.stringify(map.getCenter()));
var b = map.getBounds(); var b = map.getBounds();
ws.send(JSON.stringify({action:"bounds", south:b._southWest.lat, west:b._southWest.lng, north:b._northEast.lat, east:b._northEast.lng })); 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() }));
}); });
//map.on('contextmenu', function(e) { //map.on('contextmenu', function(e) {
@ -735,7 +735,7 @@ var addBaseMaps = function(maplist,first) {
//console.log("MAPS",first,maplist) //console.log("MAPS",first,maplist)
if (navigator.onLine) { if (navigator.onLine) {
var layerlookup = { OSMG:"OSM grey", OSMC:"OSM", OSMH:"OSM Humanitarian", EsriC:"Esri", EsriS:"Esri Satellite", var layerlookup = { OSMG:"OSM grey", OSMC:"OSM", OSMH:"OSM Humanitarian", EsriC:"Esri", EsriS:"Esri Satellite",
EsriT:"Esri Topography", EsriO:"Esri Ocean", EsriDG:"Esri Dark Grey", NatGeo: "National Geographic", EsriR:"Esri Relief", EsriT:"Esri Topography", EsriO:"Esri Ocean", EsriDG:"Esri Dark Grey", NatGeo: "National Geographic",
UKOS:"UK OS OpenData", UKOS45:"UK OS 1919-1947", UKOS00:"UK OS 1900", OpTop:"Open Topo Map", UKOS:"UK OS OpenData", UKOS45:"UK OS 1919-1947", UKOS00:"UK OS 1900", OpTop:"Open Topo Map",
HB:"Hike Bike OSM", ST:"Stamen Topography", SW: "Stamen Watercolor", AN:"AutoNavi (Chinese)" } HB:"Hike Bike OSM", ST:"Stamen Topography", SW: "Stamen Watercolor", AN:"AutoNavi (Chinese)" }
@ -794,21 +794,24 @@ var addBaseMaps = function(maplist,first) {
if (maplist.indexOf("EsriR")!==-1) { if (maplist.indexOf("EsriR")!==-1) {
basemaps[layerlookup["EsriR"]] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/{z}/{y}/{x}', { basemaps[layerlookup["EsriR"]] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/{z}/{y}/{x}', {
attribution:'Tiles © Esri', attribution:'Tiles © Esri',
maxNativeZoom:13 maxNativeZoom:13,
maxZoom:16
}); });
} }
if (maplist.indexOf("EsriO")!==-1) { if (maplist.indexOf("EsriO")!==-1) {
basemaps[layerlookup["EsriO"]] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer/tile/{z}/{y}/{x}', { basemaps[layerlookup["EsriO"]] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer/tile/{z}/{y}/{x}', {
attribution:'Tiles © Esri — Sources: GEBCO, NOAA, CHS, OSU, UNH, CSUMB, National Geographic, DeLorme, NAVTEQ, and Esri', attribution:'Tiles © Esri — Sources: GEBCO, NOAA, CHS, OSU, UNH, CSUMB, National Geographic, DeLorme, NAVTEQ, and Esri',
maxNativeZoom:13 maxNativeZoom:10,
maxZoom:13
}); });
} }
if (maplist.indexOf("EsriDG")!==-1) { if (maplist.indexOf("EsriDG")!==-1) {
basemaps[layerlookup["EsriDG"]] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/{z}/{y}/{x}', { basemaps[layerlookup["EsriDG"]] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/{z}/{y}/{x}', {
attribution: 'Tiles © Esri — Esri, DeLorme, NAVTEQ', attribution: 'Tiles © Esri — Esri, DeLorme, NAVTEQ',
maxNativeZoom:13 maxNativeZoom:16,
maxZoom:18
}); });
} }