我使用google_maps_flutter 0.5.21 + 6插件https://pub.dev/packages/google_maps_flutter
我做了文档中的所有操作,当我运行该应用程序时,没有错误,但是没有地图的空白页面。 在应用清单中添加了API密钥
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="*************"/>
我的API设置
main.dart
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
Completer<GoogleMapController> _controller = Completer();
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Column(
children: <Widget>[
Container(
height: 150,
width: 150,
child: GoogleMap(
mapType: MapType.normal,
initialCameraPosition:
CameraPosition(target: LatLng(40.712776, -74.005974), zoom: 12),
onMapCreated: (GoogleMapController controller) {
_controller.complete(controller);
},
),
)
],
),
);
}
}
调试
E / MethodChannel#flutter / platform_views(6425):位于com.google.maps.api.android.lib6.drd.pb(:com.google.android.gms.dynamite_mapsdynamite @ 19275084 @ 19.2.75(100700- 269183835):22) E / MethodChannel#flutter / platform_views(6425):位于com.google.maps.api.android.lib6.auth.da(:com.google.android.gms.dynamite_mapsdynamite @ 19275084 @ 19.2.75(100700-269183835): 82) E / MethodChannel#flutter / platform_views(6425):位于com.google.maps.api.android.lib6.impl.da(:com.google.android.gms.dynamite_mapsdynamite @ 19275084 @ 19.2.75(100700-269183835): 41) E / MethodChannel#flutter / platform_views(6425):位于com.google.android.gms.maps.internal.CreatorImpl.a(:com.google.android.gms.dynamite_mapsdynamite @ 19275084 @ 19.2.75(100700-269183835): 54) E / MethodChannel#flutter / platform_views(6425):位于com.google.android.gms.maps.internal.CreatorImpl.newMapViewDelegate(:com.google.android.gms.dynamite_mapsdynamite @ 19275084 @ 19.2.75(100700-269183835): 32) E / MethodChannel#flutter / platform_views(6425):com.google.android.gms.maps.internal.h.a(:com.google.android.gms.dynamite_mapsdynamite @ 19275084 @ 19.2.75(100700-269183835):62) E / MethodChannel#flutter / platform_views(6425):at cv.onTransact(:com.google.android.gms.dynamite_mapsdynamite @ 19275084 @ 19.2.75(100700-269183835):4) E / MethodChannel#flutter / platform_views(6425):在android.os.Binder.transact(Binder.java:667) E / MethodChannel#flutter / platform_views(6425):位于com.google.android.gms.internal.maps.zza.zza(未知来源:10) E / MethodChannel#flutter / platform_views(6425):位于com.google.android.gms.maps.internal.zzf.zza(未知来源:19) E / MethodChannel#flutter / platform_views(6425):位于com.google.android.gms.maps.MapView $ zzb.createDelegate(未知来源:13) E / MethodChannel#flutter / platform_views(6425):位于com.google.android.gms.dynamic.DeferredLifecycleHelper.zaa(未知来源:18) E / MethodChannel#flutter / platform_views(6425):位于com.google.android.gms.dynamic.DeferredLifecycleHelper.onCreate(未知来源:22) E / MethodChannel#flutter / platform_views(6425):位于com.google.android.gms.maps.MapView.onCreate(未知来源:26) E / MethodChannel#flutter / platform_views(6425):位于io.flutter.plugins.googlemaps.GoogleMapController.init(GoogleMapController.java:136) E / MethodChannel#flutter / platform_views(6425):位于io.flutter.plugins.googlemaps.GoogleMapBuilder.build(GoogleMapBuilder.java:32) E / MethodChannel#flutter / platform_views(6425):位于io.flutter.plugins.googlemaps.GoogleMapFactory.create(GoogleMapFactory.java:51) E / MethodChannel#flutter / platform_views(6425):在io.flutter.plugin.platform.SingleViewPresentation.onCreate(SingleViewPresentation.java:158) E / MethodChannel#flutter / platform_views(6425):在android.app.Dialog.dispatchOnCreate(Dialog.java:407) E / MethodChannel#flutter / platform_views(6425):在android.app.Dialog.show(Dialog.java:302) E / MethodChannel#flutter / platform_views(6425):在android.app.Presentation.show(Presentation.java:249) E / MethodChannel#flutter / platform_views(6425):位于io.flutter.plugin.platform.VirtualDisplayController。(VirtualDisplayController.java:92) E / MethodChannel#flutter / platform_views(6425):位于io.flutter.plugin.platform.VirtualDisplayController.create(VirtualDisplayController.java:52) E / MethodChannel#flutter / platform_views(6425):at io.flutter.plugin.platform.PlatformViewsController $ 1.createPlatformView(PlatformViewsController.java:97) E / MethodChannel#flutter / platform_views(6425):at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel $ 1.create(PlatformViewsChannel.java:87) E / MethodChannel#flutter / platform_views(6425):at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel $ 1.onMethodCall(PlatformViewsChannel.java:51) E / MethodChannel#flutter / platform_views(6425):位于io.flutter.plugin.common.MethodChannel $ IncomingMethodCallHandler.onMessage(MethodChannel.java:222) E / MethodChannel#flutter / platform_views(6425):at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96) E / MethodChannel#flutter / platform_views(6425):位于io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:656) E / MethodChannel#flutter / platform_views(6425):在android.os.MessageQueue.nativePollOnce(本机方法) E / MethodChannel#flutter / platform_views(6425):在android.os.MessageQueue.next(MessageQueue.java:326) E / MethodChannel#flutter / platform_views(6425):在android.os.Looper.loop(Looper.java:160) E / MethodChannel#flutter / platform_views(6425):在android.app.ActivityThread.main(ActivityThread.java:6680) E / MethodChannel#flutter / platform_views(6425):at java.lang.reflect.Method.invoke(本机方法) E / MethodChannel#flutter / platform_views(6425):在com.android.internal.os.RuntimeInit $ MethodAndArgsCaller.run(RuntimeInit.java:493) E / MethodChannel#flutter / platform_views(6425):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)