Skip to content

tiles' bounds are not wrapped before being checked against layer's bounds #1618

@ansis

Description

@ansis

Right now if you set bounds on a tile layer, and zoom out/pan you'll see that the tiles are only loaded for the first world, not later wrapped worlds. When determining if a tile should be loaded, a tile's bounds' latlng should be wrapped so that the tiles are loaded for the "next world" as well.

diff --git a/src/layer/tile/TileLayer.js b/src/layer/tile/TileLayer.js
index e1cbca0..f27eb37 100644
--- a/src/layer/tile/TileLayer.js
+++ b/src/layer/tile/TileLayer.js
@@ -356,8 +356,8 @@ L.TileLayer = L.Class.extend({
                        var tileSize = this.options.tileSize,
                            nwPoint = tilePoint.multiplyBy(tileSize),
                            sePoint = nwPoint.add([tileSize, tileSize]),
-                           nw = this._map.unproject(nwPoint),
-                           se = this._map.unproject(sePoint);
+                           nw = this._map.unproject(nwPoint).wrap(),
+                           se = this._map.unproject(sePoint).wrap();

                        if (!this.options.bounds.intersects([nw, se])) {

Is there any case where the left/right values for .wrap() should not be the defaults?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions