From 4fb075d28cf04b578757f34138e564e21151c30d Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Wed, 3 Nov 2021 21:28:22 +0000 Subject: [PATCH] add zoom to bounds, fix max zoom on layers --- CHANGELOG.md | 3 ++- README.md | 3 ++- package.json | 2 +- worldmap/worldmap.js | 17 ++++++++++------- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05faa99..b956848 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ### 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.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. diff --git a/README.md b/README.md index a6d6a3e..e9bfcb8 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,8 @@ map web page for plotting "things" on. ### 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.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. diff --git a/package.json b/package.json index 4831d05..a18142a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "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.", "dependencies": { "@turf/bezier-spline": "~6.5.0", diff --git a/worldmap/worldmap.js b/worldmap/worldmap.js index ce9c9f2..6fb22cf 100644 --- a/worldmap/worldmap.js +++ b/worldmap/worldmap.js @@ -593,7 +593,7 @@ map.on('baselayerchange', function(e) { }); function showMapCurrentZoom() { - //console.log("zoom:",map.getZoom()); + //console.log("ZOOM:",map.getZoom()); for (var l in layers) { if (layers[l].hasOwnProperty("_zoom")) { if (map.getZoom() >= clusterAt) { @@ -635,12 +635,12 @@ map.on('zoomend', function() { showMapCurrentZoom(); window.localStorage.setItem("lastzoom", map.getZoom()); 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() { window.localStorage.setItem("lastpos",JSON.stringify(map.getCenter())); 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) { @@ -735,7 +735,7 @@ var addBaseMaps = function(maplist,first) { //console.log("MAPS",first,maplist) if (navigator.onLine) { 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", 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) { basemaps[layerlookup["EsriR"]] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/{z}/{y}/{x}', { attribution:'Tiles © Esri', - maxNativeZoom:13 + maxNativeZoom:13, + maxZoom:16 }); } if (maplist.indexOf("EsriO")!==-1) { 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', - maxNativeZoom:13 + maxNativeZoom:10, + maxZoom:13 }); } 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}', { attribution: 'Tiles © Esri — Esri, DeLorme, NAVTEQ', - maxNativeZoom:13 + maxNativeZoom:16, + maxZoom:18 }); }