Skip to content
Open
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
4 changes: 2 additions & 2 deletions lib/src/node/marker_cluster_node.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ class MarkerClusterNode extends MarkerOrClusterNode {
final size = this.size();

// Calculate offset from center based on alignment
final offsetX = size.width * alignment.x * 0.5; // -0.5 to 0.5 range
final offsetY = size.height * alignment.y * 0.5; // -0.5 to 0.5 range
final offsetX = size.width * (alignment.x - 1) * 0.5; // -1 to 0 range
final offsetY = size.height * (alignment.y - 1) * 0.5; // -1 to 0 range

// Calculate top-left corner
final topLeft = Offset(
Expand Down
4 changes: 2 additions & 2 deletions lib/src/node/marker_node.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class MarkerNode extends MarkerOrClusterNode implements Marker {
final alignment = this.alignment ?? Alignment.center;

// Calculate offset from center based on alignment
final offsetX = width * alignment.x * 0.5; // -0.5 to 0.5 range
final offsetY = height * alignment.y * 0.5; // -0.5 to 0.5 range
final offsetX = width * (alignment.x - 1) * 0.5; // -1 to 0 range
final offsetY = height * (alignment.y - 1) * 0.5; // -1 to 0 range

final topLeft = Offset(center.dx + offsetX, center.dy + offsetY);
final bottomRight = Offset(topLeft.dx + width, topLeft.dy + height);
Expand Down
12 changes: 12 additions & 0 deletions test/culling_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@ void main() {
child: Icon(Icons.location_on),
);

final centre = mockCamera.projectAtZoom(marker.point);

final markerNode = MarkerNode(marker);
final bounds = markerNode.pixelBounds(mockCamera);

// Verify it returns a proper Rect
expect(bounds, isA<Rect>());
expect(bounds.left, equals(centre.dx - 20));
expect(bounds.top, equals(centre.dy - 20));
expect(bounds.width, equals(40.0));
expect(bounds.height, equals(40.0));
});
Expand All @@ -49,10 +53,14 @@ void main() {
child: Icon(Icons.location_on),
);

final centre = mockCamera.projectAtZoom(marker.point);

final markerNode = MarkerNode(marker);
final bounds = markerNode.pixelBounds(mockCamera);

expect(bounds, isA<Rect>());
expect(bounds.left, equals(centre.dx - 40));
expect(bounds.top, equals(centre.dy - 40));
expect(bounds.width, equals(40.0));
expect(bounds.height, equals(40.0));
});
Expand All @@ -66,10 +74,14 @@ void main() {
child: Icon(Icons.location_on),
);

final centre = mockCamera.projectAtZoom(marker.point);

final markerNode = MarkerNode(marker);
final bounds = markerNode.pixelBounds(mockCamera);

expect(bounds, isA<Rect>());
expect(bounds.left, equals(centre.dx));
expect(bounds.top, equals(centre.dy));
expect(bounds.width, equals(40.0));
expect(bounds.height, equals(40.0));
});
Expand Down