Skip to content

Commit

Permalink
Hack around line artifact in leaflet UI.
Browse files Browse the repository at this point in the history
This is caused by antialiasing with non fractional zoom - see Leaflet/Leaflet#3575 .

Fixes #4
  • Loading branch information
Palats committed Jan 30, 2021
1 parent e391857 commit a4a4687
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions frontend/viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,24 @@ common.globalCSS(`
}
`);

/*
* Workaround for 1px lines appearing in some browsers due to fractional transforms
* and resulting anti-aliasing.
* https://github.com/Leaflet/Leaflet/issues/3575#issuecomment-150544739
*/
function leafletHack() {
const originalInitTile = (L.GridLayer.prototype as any)._initTile;
L.GridLayer.include({
_initTile: function (tile: any) {
originalInitTile.call(this, tile);
var tileSize = this.getTileSize();
tile.style.width = tileSize.x + 1 + 'px';
tile.style.height = tileSize.y + 1 + 'px';
}
});
}
leafletHack();

export function run(config: common.MapshotConfig, info: common.MapshotJSON) {
const worldToLatLng = function (x: number, y: number) {
const ratio = info.render_size / info.tile_size;
Expand Down

0 comments on commit a4a4687

Please sign in to comment.