From 19649100ae223b5785c32755fb1dc4bafdab7313 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Wed, 1 Nov 2023 18:58:54 +0100 Subject: [PATCH] fix: repair `TileLayer.tileBounds` (#1713) --- .../layer/tile_layer/tile_bounds/tile_bounds.dart | 12 +++++------- .../tile_layer/tile_bounds/tile_bounds_at_zoom.dart | 2 +- lib/src/map/options/options.dart | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/src/layer/tile_layer/tile_bounds/tile_bounds.dart b/lib/src/layer/tile_layer/tile_bounds/tile_bounds.dart index a5e9d9c5b..99c596f67 100644 --- a/lib/src/layer/tile_layer/tile_bounds/tile_bounds.dart +++ b/lib/src/layer/tile_layer/tile_bounds/tile_bounds.dart @@ -107,7 +107,7 @@ class WrappedTileBounds extends TileBounds { ) : super._(); @override - WrappedTileBoundsAtZoom atZoom(int zoom) { + TileBoundsAtZoom atZoom(int zoom) { return _tileBoundsAtZoomCache.putIfAbsent( zoom, () => _tileBoundsAtZoomImpl(zoom)); } @@ -125,15 +125,13 @@ class WrappedTileBounds extends TileBounds { ); } - final tzDouble = zoom.toDouble(); - (int, int)? wrapX; if (crs.wrapLng case final wrapLng?) { final wrapXMin = - (crs.latLngToPoint(LatLng(0, wrapLng.$1), tzDouble).x / _tileSize) + (crs.latLngToPoint(LatLng(0, wrapLng.$1), zoomDouble).x / _tileSize) .floor(); final wrapXMax = - (crs.latLngToPoint(LatLng(0, wrapLng.$2), tzDouble).x / _tileSize) + (crs.latLngToPoint(LatLng(0, wrapLng.$2), zoomDouble).x / _tileSize) .ceil(); wrapX = (wrapXMin, wrapXMax - 1); } @@ -141,10 +139,10 @@ class WrappedTileBounds extends TileBounds { (int, int)? wrapY; if (crs.wrapLat case final wrapLat?) { final wrapYMin = - (crs.latLngToPoint(LatLng(wrapLat.$1, 0), tzDouble).y / _tileSize) + (crs.latLngToPoint(LatLng(wrapLat.$1, 0), zoomDouble).y / _tileSize) .floor(); final wrapYMax = - (crs.latLngToPoint(LatLng(wrapLat.$2, 0), tzDouble).y / _tileSize) + (crs.latLngToPoint(LatLng(wrapLat.$2, 0), zoomDouble).y / _tileSize) .ceil(); wrapY = (wrapYMin, wrapYMax - 1); } diff --git a/lib/src/layer/tile_layer/tile_bounds/tile_bounds_at_zoom.dart b/lib/src/layer/tile_layer/tile_bounds/tile_bounds_at_zoom.dart index 3f6127b32..04ef8136c 100644 --- a/lib/src/layer/tile_layer/tile_bounds/tile_bounds_at_zoom.dart +++ b/lib/src/layer/tile_layer/tile_bounds/tile_bounds_at_zoom.dart @@ -119,7 +119,7 @@ class WrappedTileBoundsAtZoom extends TileBoundsAtZoom { bool _wrappedXInRange(TileCoordinates coordinates) { final wrappedX = _wrapInt(coordinates.x, wrapX!); - return wrappedX >= tileRange.min.x && wrappedX <= tileRange.max.y; + return wrappedX >= tileRange.min.x && wrappedX <= tileRange.max.x; } bool _wrappedYInRange(TileCoordinates coordinates) { diff --git a/lib/src/map/options/options.dart b/lib/src/map/options/options.dart index bc31a8968..cf816c8c9 100644 --- a/lib/src/map/options/options.dart +++ b/lib/src/map/options/options.dart @@ -117,7 +117,7 @@ class MapOptions { /// map themselves. Without this, only the top layer may handle gestures. /// /// Note that layers that are visually obscured behind another layer will - /// recieve events, if this is enabled. + /// receive events, if this is enabled. /// /// Technically, layers become invisible to the parent `Stack` when hit /// testing (and thus `Stack` will keep bubbling gestures down all layers), but