| // Copyright 2018 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| import 'package:flutter/material.dart'; |
| import 'package:google_maps_flutter/google_maps_flutter.dart'; |
| |
| import 'page.dart'; |
| |
| class AnimateCameraPage extends Page { |
| AnimateCameraPage() |
| : super(const Icon(Icons.map), "Camera control, animated"); |
| |
| @override |
| final GoogleMapOverlayController controller = |
| new GoogleMapOverlayController.fromSize(width: 300.0, height: 200.0); |
| |
| @override |
| Widget build(BuildContext context) { |
| return new Column( |
| mainAxisAlignment: MainAxisAlignment.spaceEvenly, |
| crossAxisAlignment: CrossAxisAlignment.stretch, |
| children: <Widget>[ |
| new Center(child: new GoogleMapOverlay(controller: controller)), |
| new Row( |
| mainAxisAlignment: MainAxisAlignment.spaceEvenly, |
| children: <Widget>[ |
| new Column( |
| children: <Widget>[ |
| new FlatButton( |
| onPressed: () { |
| controller.mapController.animateCamera( |
| CameraUpdate.newCameraPosition( |
| const CameraPosition( |
| bearing: 270.0, |
| target: const LatLng(51.5160895, -0.1294527), |
| tilt: 30.0, |
| zoom: 17.0, |
| ), |
| ), |
| ); |
| }, |
| child: const Text('newCameraPosition'), |
| ), |
| new FlatButton( |
| onPressed: () { |
| controller.mapController.animateCamera( |
| CameraUpdate.newLatLng( |
| const LatLng(56.1725505, 10.1850512), |
| ), |
| ); |
| }, |
| child: const Text('newLatLng'), |
| ), |
| new FlatButton( |
| onPressed: () { |
| controller.mapController.animateCamera( |
| CameraUpdate.newLatLngBounds( |
| const LatLngBounds( |
| southwest: const LatLng(-38.483935, 113.248673), |
| northeast: const LatLng(-8.982446, 153.823821), |
| ), |
| 10.0, |
| ), |
| ); |
| }, |
| child: const Text('newLatLngBounds'), |
| ), |
| new FlatButton( |
| onPressed: () { |
| controller.mapController.animateCamera( |
| CameraUpdate.newLatLngZoom( |
| const LatLng(37.4231613, -122.087159), |
| 11.0, |
| ), |
| ); |
| }, |
| child: const Text('newLatLngZoom'), |
| ), |
| new FlatButton( |
| onPressed: () { |
| controller.mapController.animateCamera( |
| CameraUpdate.scrollBy(150.0, -225.0), |
| ); |
| }, |
| child: const Text('scrollBy'), |
| ), |
| ], |
| ), |
| new Column( |
| children: <Widget>[ |
| new FlatButton( |
| onPressed: () { |
| controller.mapController.animateCamera( |
| CameraUpdate.zoomBy( |
| -0.5, |
| const Offset(30.0, 20.0), |
| ), |
| ); |
| }, |
| child: const Text('zoomBy with focus'), |
| ), |
| new FlatButton( |
| onPressed: () { |
| controller.mapController.animateCamera( |
| CameraUpdate.zoomBy(-0.5), |
| ); |
| }, |
| child: const Text('zoomBy'), |
| ), |
| new FlatButton( |
| onPressed: () { |
| controller.mapController.animateCamera( |
| CameraUpdate.zoomIn(), |
| ); |
| }, |
| child: const Text('zoomIn'), |
| ), |
| new FlatButton( |
| onPressed: () { |
| controller.mapController.animateCamera( |
| CameraUpdate.zoomOut(), |
| ); |
| }, |
| child: const Text('zoomOut'), |
| ), |
| new FlatButton( |
| onPressed: () { |
| controller.mapController.animateCamera( |
| CameraUpdate.zoomTo(16.0), |
| ); |
| }, |
| child: const Text('zoomTo'), |
| ), |
| ], |
| ), |
| ], |
| ) |
| ], |
| ); |
| } |
| } |