【发布时间】:2020-01-27 20:05:04
【问题描述】:
我使用 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): 在 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):在 io.flutter.plugin.platform.PlatformViewsController$1.createPlatformView(PlatformViewsController.java:97) E/MethodChannel#flutter/platform_views(6425):在 io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:87) E/MethodChannel#flutter/platform_views(6425):在 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):在 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):在 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): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
【问题讨论】: