Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 808a596

Browse files
authored
trackCameraPosition is inferred from GoogleMap.onCameraMove (#1314)
* trackCameraPosition is inferred from GoogleMap.onCameraMove * Update changelog * update test * format
1 parent f84066f commit 808a596

File tree

4 files changed

+8
-17
lines changed

4 files changed

+8
-17
lines changed

packages/google_maps_flutter/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

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

67
## 0.3.0+3
78

packages/google_maps_flutter/example/lib/map_ui.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ class MapUiBodyState extends State<MapUiBody> {
175175
final GoogleMap googleMap = GoogleMap(
176176
onMapCreated: onMapCreated,
177177
initialCameraPosition: _kInitialPosition,
178-
trackCameraPosition: true,
179178
compassEnabled: _compassEnabled,
180179
cameraTargetBounds: _cameraTargetBounds,
181180
minMaxZoomPreference: _minMaxZoomPreference,

packages/google_maps_flutter/lib/src/google_map.dart

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ typedef void MapCreatedCallback(GoogleMapController controller);
99
/// Callback that receives updates to the camera position.
1010
///
1111
/// This callback is triggered when the platform Google Map
12-
/// registers a camera movement. This will be called with null if
13-
/// [GoogleMap.trackCameraPosition] is false.
12+
/// registers a camera movement.
1413
///
15-
/// This is used in [GoogleMap.onCameraMove] and [GoogleMap.onMapOptionsUpdate].
14+
/// This is used in [GoogleMap.onCameraMove].
1615
typedef void CameraPositionCallback(CameraPosition position);
1716

1817
class GoogleMap extends StatefulWidget {
@@ -28,7 +27,6 @@ class GoogleMap extends StatefulWidget {
2827
this.scrollGesturesEnabled = true,
2928
this.zoomGesturesEnabled = true,
3029
this.tiltGesturesEnabled = true,
31-
this.trackCameraPosition = false,
3230
this.myLocationEnabled = false,
3331
this.markers,
3432
this.onCameraMoveStarted,
@@ -67,9 +65,6 @@ class GoogleMap extends StatefulWidget {
6765
/// True if the map view should respond to tilt gestures.
6866
final bool tiltGesturesEnabled;
6967

70-
/// True if the map view should relay camera move events to Flutter.
71-
final bool trackCameraPosition;
72-
7368
/// Markers to be placed on the map.
7469
final Set<Marker> markers;
7570

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

8881
/// Called repeatedly as the camera continues to move after an
8982
/// onCameraMoveStarted call.
9083
///
9184
/// This may be called as often as once every frame and should
9285
/// not perform expensive operations.
93-
///
94-
/// This is only called if [trackCameraPosition] is true.
9586
final CameraPositionCallback onCameraMove;
9687

9788
/// Called when camera movement has ended, there are no pending
@@ -259,7 +250,7 @@ class _GoogleMapOptions {
259250
rotateGesturesEnabled: map.rotateGesturesEnabled,
260251
scrollGesturesEnabled: map.scrollGesturesEnabled,
261252
tiltGesturesEnabled: map.tiltGesturesEnabled,
262-
trackCameraPosition: map.trackCameraPosition,
253+
trackCameraPosition: map.onCameraMove != null,
263254
zoomGesturesEnabled: map.zoomGesturesEnabled,
264255
myLocationEnabled: map.myLocationEnabled,
265256
);

packages/google_maps_flutter/test/google_map_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ void main() {
303303
textDirection: TextDirection.ltr,
304304
child: GoogleMap(
305305
initialCameraPosition: CameraPosition(target: LatLng(10.0, 15.0)),
306-
trackCameraPosition: false,
307306
),
308307
),
309308
);
@@ -314,11 +313,12 @@ void main() {
314313
expect(platformGoogleMap.trackCameraPosition, false);
315314

316315
await tester.pumpWidget(
317-
const Directionality(
316+
Directionality(
318317
textDirection: TextDirection.ltr,
319318
child: GoogleMap(
320-
initialCameraPosition: CameraPosition(target: LatLng(10.0, 15.0)),
321-
trackCameraPosition: true,
319+
initialCameraPosition:
320+
const CameraPosition(target: LatLng(10.0, 15.0)),
321+
onCameraMove: (CameraPosition position) {},
322322
),
323323
),
324324
);

0 commit comments

Comments
 (0)