diff options
author | Guilhem Moulin <guilhem@fripost.org> | 2024-01-20 18:03:24 +0100 |
---|---|---|
committer | Guilhem Moulin <guilhem@fripost.org> | 2024-01-20 18:03:32 +0100 |
commit | c3e1dca615ceb8fb55990a950c4dbc251959199b (patch) | |
tree | 0782c3f5a530b57be5a78542efd02af8cc18868f | |
parent | 1bf9fa396b260ea8469000a9356b4839f656d468 (diff) |
Fix resolution-to-zoom logic.
-rw-r--r-- | main.js | 5 |
1 files changed, 2 insertions, 3 deletions
@@ -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}`); |