@@ -109,7 +109,50 @@ the `GoogleMap`'s `onMapCreated` callback.
109109
110110<?code-excerpt "readme_sample.dart (MapSample)"?>
111111``` dart
112+ class MapSample extends StatefulWidget {
113+ const MapSample({Key? key}) : super(key: key);
112114
115+ @override
116+ State<MapSample> createState() => MapSampleState();
117+ }
118+
119+ class MapSampleState extends State<MapSample> {
120+ final Completer<GoogleMapController> _controller =
121+ Completer<GoogleMapController>();
122+
123+ static const CameraPosition _kGooglePlex = CameraPosition(
124+ target: LatLng(37.42796133580664, -122.085749655962),
125+ zoom: 14.4746,
126+ );
127+
128+ static const CameraPosition _kLake = CameraPosition(
129+ bearing: 192.8334901395799,
130+ target: LatLng(37.43296265331129, -122.08832357078792),
131+ tilt: 59.440717697143555,
132+ zoom: 19.151926040649414);
133+
134+ @override
135+ Widget build(BuildContext context) {
136+ return Scaffold(
137+ body: GoogleMap(
138+ mapType: MapType.hybrid,
139+ initialCameraPosition: _kGooglePlex,
140+ onMapCreated: (GoogleMapController controller) {
141+ _controller.complete(controller);
142+ },
143+ ),
144+ floatingActionButton: FloatingActionButton.extended(
145+ onPressed: _goToTheLake,
146+ label: const Text('To the lake!'),
147+ icon: const Icon(Icons.directions_boat),
148+ ),
149+ );
150+ }
151+
152+ Future<void> _goToTheLake() async {
153+ final GoogleMapController controller = await _controller.future;
154+ controller.animateCamera(CameraUpdate.newCameraPosition(_kLake));
155+ }
113156```
114157
115158See the ` example ` directory for a complete sample app.
0 commit comments