Skip to content

Commit

Permalink
fix: repair TileLayer.tileBounds (#1713)
Browse files Browse the repository at this point in the history
  • Loading branch information
josxha authored Nov 1, 2023
1 parent 04e54ae commit 1964910
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
12 changes: 5 additions & 7 deletions lib/src/layer/tile_layer/tile_bounds/tile_bounds.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class WrappedTileBounds extends TileBounds {
) : super._();

@override
WrappedTileBoundsAtZoom atZoom(int zoom) {
TileBoundsAtZoom atZoom(int zoom) {
return _tileBoundsAtZoomCache.putIfAbsent(
zoom, () => _tileBoundsAtZoomImpl(zoom));
}
Expand All @@ -125,26 +125,24 @@ 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);
}

(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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/map/options/options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1964910

Please sign in to comment.