Skip to content

Instantly share code, notes, and snippets.

@ericsoco
Created July 13, 2016 19:28
Show Gist options
  • Save ericsoco/5712076f69f9068b11d41262b9e93666 to your computer and use it in GitHub Desktop.
Save ericsoco/5712076f69f9068b11d41262b9e93666 to your computer and use it in GitHub Desktop.
eliminate map tile seams in Leaflet 1.0
import leaflet from 'leaflet';
// ...
patchMapTileGapBug();
// ...
function patchMapTileGapBug () {
// Workaround for 1px lines appearing in some browsers due to fractional transforms
// and resulting anti-aliasing. adapted from @cmulders' solution:
// https://github.com/Leaflet/Leaflet/issues/3575#issuecomment-150544739
let originalInitTile = leaflet.GridLayer.prototype._initTile;
if (originalInitTile.isPatched) return;
leaflet.GridLayer.include({
_initTile: function (tile) {
originalInitTile.call(this, tile);
var tileSize = this.getTileSize();
tile.style.width = tileSize.x + 1 + 'px';
tile.style.height = tileSize.y + 1 + 'px';
}
});
leaflet.GridLayer.prototype._initTile.isPatched = true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment