Skip to content
This repository has been archived by the owner on Jul 11, 2024. It is now read-only.

Update atlas_controller.dart #164

Merged
merged 9 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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: 4 additions & 0 deletions packages/atlas/lib/src/atlas_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,8 @@ abstract class AtlasController {

/// Return a [LatLngBounds] corresponding to [Rectangle2D] the in the map view - Async method
Future<LatLngBounds>? getLatLngBounds(Rectangle2D rectangle2d);

/// Set the compass bearing of the map
/// [bearing] is the value that the bearing will become
Future<void> setMapBearing(double bearing);
robertocp25 marked this conversation as resolved.
Show resolved Hide resolved
}
11 changes: 9 additions & 2 deletions packages/atlas/lib/src/camera_position.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,30 @@ class CameraPosition {
/// Optional is the `CameraPosition` generated from a user interaction with the map
final bool? isUserUpdate;

final double? bearing;

const CameraPosition({
required this.target,
this.zoom = 0.0,
this.isUserUpdate,
this.bearing,
});

@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
if (other.runtimeType != runtimeType) return false;
if (other is CameraPosition) {
return target == other.target && zoom == other.zoom && isUserUpdate == other.isUserUpdate;
return target == other.target &&
zoom == other.zoom &&
isUserUpdate == other.isUserUpdate &&
bearing == other.bearing;
} else {
return false;
}
}
ggalambas marked this conversation as resolved.
Show resolved Hide resolved

@override
int get hashCode => target.hashCode ^ zoom.hashCode ^ isUserUpdate.hashCode;
int get hashCode =>
target.hashCode ^ zoom.hashCode ^ isUserUpdate.hashCode ^ bearing.hashCode;
}
22 changes: 14 additions & 8 deletions packages/atlas/test/camera_position_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,20 @@ main() {

test('should override hashCode properly', () {
final cameraPosition = CameraPosition(
target: LatLng(
latitude: 37.42796133580664,
longitude: -122.085749655962,
),
zoom: 10.0,
isUserUpdate: false);
expect(cameraPosition.hashCode,
cameraPosition.target.hashCode ^ cameraPosition.zoom.hashCode ^ cameraPosition.isUserUpdate.hashCode);
target: LatLng(
latitude: 37.42796133580664,
longitude: -122.085749655962,
),
zoom: 10.0,
isUserUpdate: false,
bearing: 0.0,
);
expect(
cameraPosition.hashCode,
cameraPosition.target.hashCode ^
cameraPosition.zoom.hashCode ^
cameraPosition.isUserUpdate.hashCode ^
cameraPosition.bearing.hashCode);
});
});
}
Loading