如何让谷歌地图在flutter中工作



我已经按照包的开发页面上的步骤进行了操作:https://pub.dev/packages/google_maps_flutter但当我在输入api键后运行它时,我得到的只是一个空白屏幕,如下所示:
屏幕截图

AndroidManifest.xml看起来像这样:

<application
android:name="io.flutter.app.FlutterApplication"
android:label="foodiesapp"
android:icon="@mipmap/ic_launcher">   
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in @style/LaunchTheme). -->
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyB........"/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>

主页面是软件包开发页面示例中的确切代码:https://pub.dev/packages/google_maps_flutter

有人知道问题可能是什么吗?

将API_KEY元数据移动到主活动上方。

<application
android:name="io.flutter.app.FlutterApplication"
android:label="foodiesapp"
android:icon="@mipmap/ic_launcher">
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyB........"/> <!--here-->
<activity
android:name=".MainActivity"
android:launchMode="singleTop"

相关内容

  • 没有找到相关文章

最新更新