From f31829f94d5295ff2f09e7b82671177f1605bc10 Mon Sep 17 00:00:00 2001 From: Alexis Rouillard Date: Tue, 13 Feb 2024 18:28:38 +0100 Subject: [PATCH] Fix: repaint polygons/polylines on changes. (#1825) --- lib/src/layer/polygon_layer/painter.dart | 11 +++++++---- lib/src/layer/polyline_layer/painter.dart | 9 +++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/src/layer/polygon_layer/painter.dart b/lib/src/layer/polygon_layer/painter.dart index af5457eaa..cf62b141c 100644 --- a/lib/src/layer/polygon_layer/painter.dart +++ b/lib/src/layer/polygon_layer/painter.dart @@ -306,9 +306,12 @@ class _PolygonPainter extends CustomPainter { path.addPolygon(offsets, true); } - // TODO: Fix bug where wrapping layer in some widgets (eg. opacity) causes the - // features to not move unless this is `true`, but `true` significantly impacts - // performance @override - bool shouldRepaint(_PolygonPainter oldDelegate) => false; + bool shouldRepaint(_PolygonPainter oldDelegate) => + polygons != oldDelegate.polygons || + triangles != oldDelegate.triangles || + camera != oldDelegate.camera || + bounds != oldDelegate.bounds || + drawLabelsLast != oldDelegate.drawLabelsLast || + polygonLabels != oldDelegate.polygonLabels; } diff --git a/lib/src/layer/polyline_layer/painter.dart b/lib/src/layer/polyline_layer/painter.dart index 9b9a4c4b1..9b3fe2626 100644 --- a/lib/src/layer/polyline_layer/painter.dart +++ b/lib/src/layer/polyline_layer/painter.dart @@ -288,11 +288,12 @@ class _PolylinePainter extends CustomPainter { LatLng _unproject(DoublePoint p0) => camera.crs.projection.unprojectXY(p0.x, p0.y); - // TODO: Fix bug where wrapping layer in some widgets (eg. opacity) causes the - // features to not move unless this is `true`, but `true` significantly impacts - // performance @override - bool shouldRepaint(_PolylinePainter oldDelegate) => false; + bool shouldRepaint(_PolylinePainter oldDelegate) => + polylines != oldDelegate.polylines || + camera != oldDelegate.camera || + hitNotifier != oldDelegate.hitNotifier || + minimumHitbox != oldDelegate.minimumHitbox; } const _distance = Distance();