aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2024-01-20 18:03:24 +0100
committerGuilhem Moulin <guilhem@fripost.org>2024-01-20 18:03:32 +0100
commitc3e1dca615ceb8fb55990a950c4dbc251959199b (patch)
tree0782c3f5a530b57be5a78542efd02af8cc18868f
parent1bf9fa396b260ea8469000a9356b4839f656d468 (diff)
Fix resolution-to-zoom logic.
-rw-r--r--main.js5
1 files 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}`);