Created
July 13, 2016 19:28
-
-
Save ericsoco/5712076f69f9068b11d41262b9e93666 to your computer and use it in GitHub Desktop.
eliminate map tile seams in Leaflet 1.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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