From 47ae47d123a41e85669d18741f1392eb241152e3 Mon Sep 17 00:00:00 2001 From: Hannes Date: Fri, 25 Sep 2020 22:06:20 +0200 Subject: [PATCH 1/2] zoom can actually be fractional nowadays --- examples/permalink.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/permalink.js b/examples/permalink.js index c62ee3e4f7..3a8a3ae16a 100644 --- a/examples/permalink.js +++ b/examples/permalink.js @@ -13,7 +13,7 @@ if (window.location.hash !== '') { const hash = window.location.hash.replace('#map=', ''); const parts = hash.split('/'); if (parts.length === 4) { - zoom = parseInt(parts[0], 10); + zoom = parseFloat(parts[0]); center = [parseFloat(parts[1]), parseFloat(parts[2])]; rotation = parseFloat(parts[3]); } From 2e87ae34218bae036e20f82b589114b6b0580771 Mon Sep 17 00:00:00 2001 From: Hannes Date: Fri, 25 Sep 2020 22:10:25 +0200 Subject: [PATCH 2/2] use .toFixed() instead of manual math --- examples/permalink.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/permalink.js b/examples/permalink.js index 3a8a3ae16a..db1bd360d8 100644 --- a/examples/permalink.js +++ b/examples/permalink.js @@ -45,11 +45,11 @@ const updatePermalink = function () { const center = view.getCenter(); const hash = '#map=' + - view.getZoom() + + view.getZoom().toFixed(2) + '/' + - Math.round(center[0] * 100) / 100 + + center[0].toFixed(2) + '/' + - Math.round(center[1] * 100) / 100 + + center[1].toFixed(2) + '/' + view.getRotation(); const state = {