From c3e1dca615ceb8fb55990a950c4dbc251959199b Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Sat, 20 Jan 2024 18:03:24 +0100 Subject: Fix resolution-to-zoom logic. --- main.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/main.js b/main.js index f5cf41a..4764407 100644 --- a/main.js +++ b/main.js @@ -104,7 +104,6 @@ const baseMapSource = new WMTS({ }); -const resolutions = [1024, 512, 256, 128, 64, 32, 16, 8]; const view = new View({ projection: projection, extent: extent, @@ -113,7 +112,7 @@ const view = new View({ center: [694767.48, 7338176.57], zoom: 1, enableRotation: false, - resolutions: resolutions, + resolutions: [1024, 512, 256, 128, 64, 32, 16, 8], constrainResolution: false, }); @@ -582,7 +581,7 @@ map.addLayer(new VectorTileLayer({ return style; } else { const maxi = style.length - 1; - const z = resolutions.length - 2 - Math.log2(resolution); + const z = 10 /* Math.log2(maxResolution) */ - Math.log2(resolution); /* use Math.floor() as VectorTile.js calls getZForResolution(resolution, 1) */ const i = z <= 0 ? 0 : z >= maxi ? maxi : Math.floor(z); // console.log(`resolution=${resolution}, z=${z}, i=${i}`); -- cgit v1.2.3