@@ -16,15 +16,15 @@ This plugin provides an *unpublished preview* of the Flutter API for Google Maps
1616 widgets is * inherently limited* and will be replaced by a fully compositional
1717 [ Texture] ( https://docs.flutter.io/flutter/widgets/Texture-class.html ) -based
1818 approach before we publish this plugin.
19-
19+
2020 In detail: the plugin currently relies on placing platform overlays on top of
2121 a bitmap snapshotting widget for creating the illusion of in-line compositing
2222 of GoogleMap views with Flutter widgets. This works only in very limited
2323 situations where
2424 * the widget is stationary
2525 * the widget is drawn on top of all other widgets within bounds
2626 * touch events within widget bounds can be safely ignored by Flutter
27-
27+
2828 The root problem with platform overlays is that they cannot be freely composed
2929 with other widgets. Many workarounds can be devised to address this shortcoming
3030 in particular situations, but the Flutter team does not intend to support such
@@ -48,7 +48,7 @@ Get an API key at <https://cloud.google.com/maps-platform/>.
4848
4949### Android
5050
51- Specify your API key in the application manifest ` android/src/main/AndroidManifest.xml`:
51+ Specify your API key in the application manifest ` android/app/ src/main/AndroidManifest.xml`:
5252
5353` ` ` xml
5454<manifest ...
@@ -89,29 +89,54 @@ the overlay controller. Client code written against the `GoogleMapController`
8989interface will be unaffected by the change away from platform overlays.
9090
9191` ` ` dart
92- final GoogleMapOverlayController controller =
93- GoogleMapOverlayController.fromSize(width: 300.0, height: 200.0);
94-
95- @override
96- Widget build(BuildContext context) {
97- return Column(children: <Widget>[
98- Center(child: GoogleMapOverlay(controller: controller)),
99- FlatButton(
100- child: const Text('Go to London'),
101- onPressed: () {
102- controller.mapController.animateCamera(
103- CameraUpdate.newCameraPosition(
104- const CameraPosition(
105- bearing: 270.0,
106- target: LatLng(51.5160895, -0.1294527),
107- tilt: 30.0,
108- zoom: 17.0,
109- ),
110- )
111- );
112- }
92+ import 'package:flutter/material.dart';
93+ import 'package:google_maps_flutter/google_maps_flutter.dart';
94+
95+ void main() {
96+ GoogleMapController.init();
97+ final GoogleMapOverlayController controller =
98+ GoogleMapOverlayController.fromSize(width: 300.0, height: 200.0);
99+ final Widget mapWidget = GoogleMapOverlay(controller: controller);
100+ runApp(MaterialApp(
101+ home: new Scaffold(
102+ appBar: AppBar(title: const Text('Google Maps demo')),
103+ body: MapsDemo(mapWidget, controller.mapController),
113104 ),
114- ]);
105+ navigatorObservers: <NavigatorObserver>[controller.overlayController],
106+ ));
107+ }
108+
109+ class MapsDemo extends StatelessWidget {
110+ MapsDemo(this.mapWidget, this.controller);
111+
112+ final Widget mapWidget;
113+ final GoogleMapController controller;
114+
115+ @override
116+ Widget build(BuildContext context) {
117+ return Padding(
118+ padding: EdgeInsets.all(15.0),
119+ child: Column(
120+ mainAxisAlignment: MainAxisAlignment.spaceEvenly,
121+ children: <Widget>[
122+ Center(child: mapWidget),
123+ RaisedButton(
124+ child: const Text('Go to London'),
125+ onPressed: () {
126+ controller.animateCamera(CameraUpdate.newCameraPosition(
127+ const CameraPosition(
128+ bearing: 270.0,
129+ target: LatLng(51.5160895, -0.1294527),
130+ tilt: 30.0,
131+ zoom: 17.0,
132+ ),
133+ ));
134+ },
135+ ),
136+ ],
137+ ),
138+ );
139+ }
115140}
116141` ` `
117142
0 commit comments