user13374179
user13374179

Reputation:

Flutter + Google Maps: How to animate the camera to target location

i was wondering if you could give me an example on "animating" the camera of a map to a target location based on latitude and longitude.

Sorry I'm just very new to flutter. Thanks in advance.

Upvotes: 2

Views: 2775

Answers (1)

Can
Can

Reputation: 1876

Take a look at the official google_maps_flutter page. It has exactly the same example you are looking for.

Basically, you can control the camera with the GoogleMapController object after initializing it with the onMapCreated callback of the GoogleMap widget.

Future<void> _goToTheLake() async {
  final GoogleMapController controller = await _controller.future;
  controller.animateCamera(CameraUpdate.newCameraPosition(_kLake));
 }

Upvotes: 2

Related Questions