make background map tile edges opaque

Replaces the workaround of the tile rendering issues on Chrome at odd zoom levels.

The svg filter `#alpha-slope5` alters the alpha channel of background tiles such that everything but (almost) transparent pixels are rendered fully opaque.

closes #10747
This commit is contained in:
Martin Raifer
2025-02-10 13:44:17 +01:00
parent 97600e3ce8
commit 9e110cfda4
4 changed files with 30 additions and 36 deletions
+1 -22
View File
@@ -16,30 +16,9 @@ export function rendererTileLayer(context) {
var _zoom;
var _source;
var _underzoom = 0;
var _epsilon = 0;
// Workaround to remove visible grid around tile borders on Chrome with dynamic epsilon for specific browser zoom levels
// Should be removed when https://issues.chromium.org/issues/40084005 is resolved
// See https://github.com/openstreetmap/iD/pull/10594
if (window.chrome) {
updateEpsilon();
window.addEventListener('resize', updateEpsilon);
}
function updateEpsilon() {
const pageZoom = Math.round(window.devicePixelRatio * 100);
if (pageZoom % 25 === 0) {
_epsilon = 0; // uses mix-blend-mode: plus-lighter
} else if (pageZoom === 90) {
_epsilon = 0.005;
} else if (pageZoom === 110) {
_epsilon = 0.002;
} else {
_epsilon = 0.003;
}
}
function tileSizeAtZoom(d, z) {
return ((d.tileSize * Math.pow(2, z - d[2])) / d.tileSize) + _epsilon;
return (d.tileSize * Math.pow(2, z - d[2])) / d.tileSize;
}