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 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: 4 additions & 0 deletions packages/atlas/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# atlas

## v1.0.17 (2024-01-15)

- Add `setBearing` to atlas controller

## v1.0.16 (2024-01-10)

- Update polyline properties
Expand Down
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> setBearing(double bearing);
}
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;
}
2 changes: 1 addition & 1 deletion packages/atlas/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: atlas
description: An extensible map abstraction for Flutter with support for multiple map providers
version: 1.0.16
version: 1.0.17
repository: https://github.com/bmw-tech/atlas
issue_tracker: https://github.com/bmw-tech/atlas/issues
homepage: https://bmw-tech.github.io/atlas
Expand Down
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