Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
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
1 change: 1 addition & 0 deletions packages/google_maps_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* Change events are call backs on GoogleMap widget.
* GoogleMapController no longer handles change events.
* trackCameraPosition is inferred from GoogleMap.onCameraMove being set.

## 0.3.0+3

Expand Down
1 change: 0 additions & 1 deletion packages/google_maps_flutter/example/lib/map_ui.dart
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ class MapUiBodyState extends State<MapUiBody> {
final GoogleMap googleMap = GoogleMap(
onMapCreated: onMapCreated,
initialCameraPosition: _kInitialPosition,
trackCameraPosition: true,
compassEnabled: _compassEnabled,
cameraTargetBounds: _cameraTargetBounds,
minMaxZoomPreference: _minMaxZoomPreference,
Expand Down
15 changes: 3 additions & 12 deletions packages/google_maps_flutter/lib/src/google_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ typedef void MapCreatedCallback(GoogleMapController controller);
/// Callback that receives updates to the camera position.
///
/// This callback is triggered when the platform Google Map
/// registers a camera movement. This will be called with null if
/// [GoogleMap.trackCameraPosition] is false.
/// registers a camera movement.
///
/// This is used in [GoogleMap.onCameraMove] and [GoogleMap.onMapOptionsUpdate].
/// This is used in [GoogleMap.onCameraMove].
typedef void CameraPositionCallback(CameraPosition position);

class GoogleMap extends StatefulWidget {
Expand All @@ -28,7 +27,6 @@ class GoogleMap extends StatefulWidget {
this.scrollGesturesEnabled = true,
this.zoomGesturesEnabled = true,
this.tiltGesturesEnabled = true,
this.trackCameraPosition = false,
this.myLocationEnabled = false,
this.markers,
this.onCameraMoveStarted,
Expand Down Expand Up @@ -67,9 +65,6 @@ class GoogleMap extends StatefulWidget {
/// True if the map view should respond to tilt gestures.
final bool tiltGesturesEnabled;

/// True if the map view should relay camera move events to Flutter.
final bool trackCameraPosition;

/// Markers to be placed on the map.
final Set<Marker> markers;

Expand All @@ -81,17 +76,13 @@ class GoogleMap extends StatefulWidget {
/// 2. Programmatically initiated animation.
/// 3. Camera motion initiated in response to user gestures on the map.
/// For example: pan, tilt, pinch to zoom, or rotate.
///
/// Note: This is callback is called even if [trackCameraPosition] is false.
final VoidCallback onCameraMoveStarted;

/// Called repeatedly as the camera continues to move after an
/// onCameraMoveStarted call.
///
/// This may be called as often as once every frame and should
/// not perform expensive operations.
///
/// This is only called if [trackCameraPosition] is true.
final CameraPositionCallback onCameraMove;

/// Called when camera movement has ended, there are no pending
Expand Down Expand Up @@ -259,7 +250,7 @@ class _GoogleMapOptions {
rotateGesturesEnabled: map.rotateGesturesEnabled,
scrollGesturesEnabled: map.scrollGesturesEnabled,
tiltGesturesEnabled: map.tiltGesturesEnabled,
trackCameraPosition: map.trackCameraPosition,
trackCameraPosition: map.onCameraMove != null,
zoomGesturesEnabled: map.zoomGesturesEnabled,
myLocationEnabled: map.myLocationEnabled,
);
Expand Down
8 changes: 4 additions & 4 deletions packages/google_maps_flutter/test/google_map_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ void main() {
textDirection: TextDirection.ltr,
child: GoogleMap(
initialCameraPosition: CameraPosition(target: LatLng(10.0, 15.0)),
trackCameraPosition: false,
),
),
);
Expand All @@ -314,11 +313,12 @@ void main() {
expect(platformGoogleMap.trackCameraPosition, false);

await tester.pumpWidget(
const Directionality(
Directionality(
textDirection: TextDirection.ltr,
child: GoogleMap(
initialCameraPosition: CameraPosition(target: LatLng(10.0, 15.0)),
trackCameraPosition: true,
initialCameraPosition:
const CameraPosition(target: LatLng(10.0, 15.0)),
onCameraMove: (CameraPosition position) {},
),
),
);
Expand Down