diff --git a/packages/google_maps_flutter/CHANGELOG.md b/packages/google_maps_flutter/CHANGELOG.md index 36915e553bd0..f02bb0961266 100644 --- a/packages/google_maps_flutter/CHANGELOG.md +++ b/packages/google_maps_flutter/CHANGELOG.md @@ -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 diff --git a/packages/google_maps_flutter/example/lib/map_ui.dart b/packages/google_maps_flutter/example/lib/map_ui.dart index 486d87b9073c..d3661218578e 100644 --- a/packages/google_maps_flutter/example/lib/map_ui.dart +++ b/packages/google_maps_flutter/example/lib/map_ui.dart @@ -175,7 +175,6 @@ class MapUiBodyState extends State { final GoogleMap googleMap = GoogleMap( onMapCreated: onMapCreated, initialCameraPosition: _kInitialPosition, - trackCameraPosition: true, compassEnabled: _compassEnabled, cameraTargetBounds: _cameraTargetBounds, minMaxZoomPreference: _minMaxZoomPreference, diff --git a/packages/google_maps_flutter/lib/src/google_map.dart b/packages/google_maps_flutter/lib/src/google_map.dart index fca62f1ca5b7..9f609c131d13 100644 --- a/packages/google_maps_flutter/lib/src/google_map.dart +++ b/packages/google_maps_flutter/lib/src/google_map.dart @@ -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 { @@ -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, @@ -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 markers; @@ -81,8 +76,6 @@ 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 @@ -90,8 +83,6 @@ class GoogleMap extends StatefulWidget { /// /// 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 @@ -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, ); diff --git a/packages/google_maps_flutter/test/google_map_test.dart b/packages/google_maps_flutter/test/google_map_test.dart index 50c36744f607..833ae0cece0f 100644 --- a/packages/google_maps_flutter/test/google_map_test.dart +++ b/packages/google_maps_flutter/test/google_map_test.dart @@ -303,7 +303,6 @@ void main() { textDirection: TextDirection.ltr, child: GoogleMap( initialCameraPosition: CameraPosition(target: LatLng(10.0, 15.0)), - trackCameraPosition: false, ), ), ); @@ -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) {}, ), ), );