Animating a map camera to a location

We have added a row of buttons where the user can press to focus on a specific place. By tapping on one of these buttons, a new method will be called, _animateMapCameraTo, for Stonehenge, for example:

RaisedButton(
child: Text("Stonehenge"),
onPressed: () {
_animateMapCameraTo(_stonehengePosition);
},
),

The new method is responsible for requesting the camera update:

  void _animateMapCameraTo(LatLng position) {
_mapController.animateCamera(CameraUpdate.newLatLng(position));
}

As you can see, through the GoogleMapController instance retrieved before, we can dispatch a camera animation to a new location on the map.

The code for other buttons are very similar. Again, check hands_on_maps on GitHub for full details of the map integration example.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.134.104.173