question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Space between tiles on fractional zoom levels

See original GitHub issue

Note

This issue now has 150+ comments, most of which are concerned with hacky workarounds. I’ve compiled a list of a few comments that are discussing potential solutions:

(See also https://github.com/Leaflet/Leaflet/issues/3575#issuecomment-1108533500.)

Relevant browser bugs, filed by @hyperknot:

/@Malvoz

screen shot 2015-06-30 at 14 39 12

As the screenshot shows there is a small space between the tiles. This happens to me on fractional zoom levels in Safari, Chrome and Opera. It seems like this was fixed in #2377 but later removed in 3ccbe5b in favour of better performance.

I tried reimplementing the fix to see the performance impact myself and it was pretty bad furthermore it didn’t even fix the problem for Chrome.

Does anyone have an idea how this can be fixed? Fractional zoom levels would be a great feature for our app but as long as this bug remains we can’t really use them.

Edit: I set up a jsFiddle that shows the problem: http://jsfiddle.net/Eschon/pw9jcjus/1/

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:30
  • Comments:176 (61 by maintainers)

github_iconTop GitHub Comments

37reactions
cmulderscommented, Oct 23, 2015

Especially on darker maps or images (in my case) the issue is quite noticeable. I think that antialiasing in the browser causes the spaces between tiles due to the fractional transform during zooming, as mentioned by Ivan.

Until a better solution is available, I will use this workaround (or hack) to make the tiles 1 pixel larger, with the side effect that they overlap by 1 px. Besides that the tiles will be slightly enlarged and scaled (by 1px).

/* 
 * Workaround for 1px lines appearing in some browsers due to fractional transforms
 * and resulting anti-aliasing.
 * https://github.com/Leaflet/Leaflet/issues/3575
 */
(function(){
    var originalInitTile = L.GridLayer.prototype._initTile
    L.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';
        }
    });
})()
23reactions
ChrisLowe-Takorcommented, Sep 8, 2020

I’ve found a fix that’s stupid and really shouldn’t work.

.leaflet-tile-container img {
    width: 256.5px !important;
    height: 256.5px !important;
}

This should result in massive jarring seams around the tiles but I can’t see them at all and it fixes the space between the tiles.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fractional zoom levels - Stack Overflow
I'd like to have the drawable area fill up as much space as possible within the map div while still showing the entire...
Read more >
Developers - Space between tiles on fractional zoom levels in ...
As the screenshot shows there is a small space between the tiles. This happens to me on fractional zoom levels in Safari, Chrome...
Read more >
How to update tile source URL at zoom change
For any particular view zoom level (which may be fractional) tiles will be fetched for nearest appropriate integer tile grid zoom level (the ......
Read more >
6. Zoom Level - WebGIS Tutorial
Fractional scaling is a new concept proposed in Leaflet 1.0.0. Prior to this, the map's zoom level can only be an integer (0,...
Read more >
Prototyping a Smoother Map. A glimpse into how Google ...
By the time it hits zoom level 21 the map is 2 million tiles wide, ... the fractional x and y pixel on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found