diff --git a/src/geo/transform.js b/src/geo/transform.js index 69a26df4bd7..0e9c1eb713e 100644 --- a/src/geo/transform.js +++ b/src/geo/transform.js @@ -140,6 +140,25 @@ class Transform { ); } + /** + * Return any "wrapped" copies of a given tile coordinate that are visible + * in the current view. + * + * @private + */ + getVisibleWrappedCoordinates(tileCoord) { + const ul = this.pointCoordinate(new Point(0, 0), 0); + const ur = this.pointCoordinate(new Point(this.width, 0), 0); + const w0 = Math.floor(ul.column); + const w1 = Math.floor(ur.column); + const result = [tileCoord]; + for (let w = w0; w <= w1; w++) { + if (w === 0) continue; + result.push(new TileCoord(tileCoord.z, tileCoord.x, tileCoord.y, w)); + } + return result; + } + /** * Return all coordinates that could cover this transform for a covering * zoom level. diff --git a/src/source/source_cache.js b/src/source/source_cache.js index cd94a9a04e5..b503a6f5121 100644 --- a/src/source/source_cache.js +++ b/src/source/source_cache.js @@ -327,7 +327,7 @@ class SourceCache extends Evented { if (!this.used) { visibleCoords = []; } else if (this._source.coord) { - visibleCoords = [this._source.coord]; + visibleCoords = transform.getVisibleWrappedCoordinates(this._source.coord); } else { visibleCoords = transform.coveringTiles({ tileSize: this._source.tileSize, diff --git a/test/integration/render-tests/regressions/mapbox-gl-js#4551/expected.png b/test/integration/render-tests/regressions/mapbox-gl-js#4551/expected.png new file mode 100644 index 00000000000..f72022dd3ae Binary files /dev/null and b/test/integration/render-tests/regressions/mapbox-gl-js#4551/expected.png differ diff --git a/test/integration/render-tests/regressions/mapbox-gl-js#4551/style.json b/test/integration/render-tests/regressions/mapbox-gl-js#4551/style.json new file mode 100644 index 00000000000..f8fbf52acd9 --- /dev/null +++ b/test/integration/render-tests/regressions/mapbox-gl-js#4551/style.json @@ -0,0 +1,35 @@ +{ + "version": 8, + "metadata": { + "test": { + "skipped": { + "native": "https://github.com/mapbox/mapbox-gl-native/issues/1350" + }, + "width": 128, + "height": 64 + } + }, + "center": [-180, 0], + "sources": { + "image": { + "type": "image", + "coordinates": [ + [ -180, 45 ], + [ 180, 45 ], + [ 180, -45 ], + [ -180, -45 ] + ], + "url": "local://image/0.png" + } + }, + "layers": [ + { + "id": "image", + "type": "raster", + "source": "image", + "paint": { + "raster-fade-duration": 0 + } + } + ] +}