Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/src/layer/polygon_layer/polygon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class Polygon<R extends Object> {

LatLngBounds? _boundingBox;

/// Get the bounding box of the [Polygon.points] (cached).
/// Get the bounding box of the [points] (cached).
LatLngBounds get boundingBox =>
_boundingBox ??= LatLngBounds.fromPoints(points);

Expand Down
6 changes: 6 additions & 0 deletions lib/src/layer/polyline_layer/polyline.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ class Polyline<R extends Object> {
/// {@macro fm.hde.hitValue}
final R? hitValue;

LatLngBounds? _boundingBox;

/// Get the bounding box of the [points] (cached).
LatLngBounds get boundingBox =>
_boundingBox ??= LatLngBounds.fromPoints(points);

/// Create a new [Polyline] used for the [PolylineLayer].
Polyline({
required this.points,
Expand Down
4 changes: 4 additions & 0 deletions lib/src/layer/polyline_layer/polyline_layer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ class _PolylineLayerState<R extends Object> extends State<PolylineLayer<R>>
for (final projectedPolyline in polylines) {
final polyline = projectedPolyline.polyline;

// Test bounding boxes to avoid potentially expensive aggressive culling
// when none of the line is visible
if (!boundsAdjusted.isOverlapping(polyline.boundingBox)) continue;

// Gradient poylines cannot be easily segmented
if (polyline.gradientColors != null) {
yield projectedPolyline;
Expand Down
Loading