From 952d1d7f46e94f8d6a426b35e3c7baf00afd3456 Mon Sep 17 00:00:00 2001 From: monsieurtanuki Date: Mon, 5 Aug 2024 18:46:07 +0200 Subject: [PATCH 1/3] fix: 1934 - polygon hit even with rotated maps --- lib/src/layer/polygon_layer/painter.dart | 3 --- lib/src/layer/polyline_layer/painter.dart | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/src/layer/polygon_layer/painter.dart b/lib/src/layer/polygon_layer/painter.dart index 1adbd03f6..c883f409a 100644 --- a/lib/src/layer/polygon_layer/painter.dart +++ b/lib/src/layer/polygon_layer/painter.dart @@ -53,9 +53,6 @@ base class _PolygonPainter required LatLng coordinate, }) { final polygon = projectedPolygon.polygon; - if (!polygon.boundingBox.contains(coordinate)) { - return false; - } final projectedCoords = getOffsetsXY( camera: camera, diff --git a/lib/src/layer/polyline_layer/painter.dart b/lib/src/layer/polyline_layer/painter.dart index 3b4e25a67..263c7739d 100644 --- a/lib/src/layer/polyline_layer/painter.dart +++ b/lib/src/layer/polyline_layer/painter.dart @@ -31,6 +31,8 @@ base class _PolylinePainter // if (!polyline.boundingBox.contains(touch)) { // continue; // } + // Be careful with map orientation, though, and try to code similar things + // for polygons. final offsets = getOffsetsXY( camera: camera, From 415085f34c2aecbff55e498b1e85a1514cec8b3d Mon Sep 17 00:00:00 2001 From: JaffaKetchup Date: Tue, 6 Aug 2024 22:55:35 +0200 Subject: [PATCH 2/3] Fixed lint issue & added TODO --- lib/src/layer/polygon_layer/painter.dart | 7 ++++++- lib/src/layer/polyline_layer/painter.dart | 10 +++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/src/layer/polygon_layer/painter.dart b/lib/src/layer/polygon_layer/painter.dart index c883f409a..878bea4ea 100644 --- a/lib/src/layer/polygon_layer/painter.dart +++ b/lib/src/layer/polygon_layer/painter.dart @@ -52,7 +52,12 @@ base class _PolygonPainter required math.Point point, required LatLng coordinate, }) { - final polygon = projectedPolygon.polygon; + // TODO: We should check the bounding box here, for efficiency + // However, we need to account for map rotation + // + // if (!polygon.boundingBox.contains(touch)) { + // continue; + // } final projectedCoords = getOffsetsXY( camera: camera, diff --git a/lib/src/layer/polyline_layer/painter.dart b/lib/src/layer/polyline_layer/painter.dart index 263c7739d..1f60aee39 100644 --- a/lib/src/layer/polyline_layer/painter.dart +++ b/lib/src/layer/polyline_layer/painter.dart @@ -25,14 +25,14 @@ base class _PolylinePainter }) { final polyline = projectedPolyline.polyline; - // TODO: For efficiency we'd ideally filter by bounding box here. However - // we'd need to compute an extended bounding box that accounts account for - // the `borderStrokeWidth` & the `minimumHitbox` + // TODO: We should check the bounding box here, for efficiency + // However, we need to account for: + // * map rotation + // * extended bbox that accounts for `minimumHitbox` + // // if (!polyline.boundingBox.contains(touch)) { // continue; // } - // Be careful with map orientation, though, and try to code similar things - // for polygons. final offsets = getOffsetsXY( camera: camera, From 46d00a343b0d49381fe7a282a5b95743b7043510 Mon Sep 17 00:00:00 2001 From: JaffaKetchup Date: Tue, 6 Aug 2024 22:58:32 +0200 Subject: [PATCH 3/3] Fixed unrelated lint --- lib/src/layer/tile_layer/tile_layer.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/layer/tile_layer/tile_layer.dart b/lib/src/layer/tile_layer/tile_layer.dart index c0b8e19e2..09c0e75f5 100644 --- a/lib/src/layer/tile_layer/tile_layer.dart +++ b/lib/src/layer/tile_layer/tile_layer.dart @@ -347,7 +347,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { late final _resetSub = widget.reset?.listen((_) { _tileImageManager.removeAll(widget.evictErrorTileStrategy); - _loadAndPruneInVisibleBounds(MapCamera.of(context)); + if (mounted) _loadAndPruneInVisibleBounds(MapCamera.of(context)); }); // This is called on every map movement so we should avoid expensive logic