Skip to content

Commit fcdf4ef

Browse files
authored
Review comments (flutter#554)
1 parent e8dc380 commit fcdf4ef

File tree

3 files changed

+52
-27
lines changed

3 files changed

+52
-27
lines changed

packages/google_maps_flutter/README.md

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -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`
8989
interface 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

packages/google_maps_flutter/example/android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
android:value="@integer/google_play_services_version" />
1313
<meta-data
1414
android:name="com.google.android.geo.API_KEY"
15-
android:value="AIzaSyA81lRAuYToAhii3Wohpx7KrkoDhW_4XV0" />
15+
android:value="YOUR KEY HERE" />
1616
<activity
1717
android:name=".MainActivity"
1818
android:launchMode="singleTop"

packages/google_maps_flutter/example/ios/Runner/AppDelegate.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ @implementation AppDelegate
77
- (BOOL)application:(UIApplication *)application
88
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
99
// Provide the GoogleMaps API key.
10-
[GMSServices provideAPIKey:@"AIzaSyBCGQ3UNVvpeJTUr07qcEmtHQmllJs4SV0"];
10+
[GMSServices provideAPIKey:@"YOUR KEY HERE"];
1111

1212
// Register Flutter plugins.
1313
[GeneratedPluginRegistrant registerWithRegistry:self];

0 commit comments

Comments
 (0)