google-maps - Flutter:如何在谷歌地图中显示位置图层

标签 google-maps dart flutter

我目前无法使用 google_maps_flutter 在 Flutter 应用程序中的嵌入式 GoogleMap 中显示位置层包裹。我已经在 AndroidManifest.xml 和 Info.plist 文件中声明了所需的权限,并将 map 的 myLocationEnabled 属性设置为 true。生成的 map 既不显示当前位置图标,也不显示“我的位置”按钮。

this等问题似乎暗示可能需要另一个依赖项才能显示 Google map 位置层。但是,我不认为是这种情况。

我是否遗漏了当前方法中的某些内容,或者我是否需要额外的依赖项?

我在我的 AndroidManifest.xml 中包含了以下内容:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

以及我的 Info.plist 中的以下内容:

<key>io.flutter.embedded_views_preview</key>
<true/>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Application needs to access your current location</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Application needs to access your current location</string>

map 代码:

return GoogleMap(
          mapType: MapType.normal,
          initialCameraPosition: _lakeGenevaPos,
          markers: _markers,
          polylines: _polylines,
          myLocationEnabled: true,
          onMapCreated: (GoogleMapController controller) => _onMapCreated(controller),
        );

pubspec.yaml 依赖:

google_maps_flutter: ^0.5.13

最佳答案

你应该相信那个场景:)

在 IOS 中它应该可以工作。在 Android 中也检查我的答案:

Geolocator Plugin to get current location

关于google-maps - Flutter:如何在谷歌地图中显示位置图层,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56202184/

相关文章:

javascript - 谷歌地图库加载阻止页面

android - 膨胀类 com.google.android.maps.MapView 时出错

debugging - Dart DevTools显示 "Connect to a running app"

firebase - 如何使用 firestore 在当前用户文档中添加数据?

dart - 有什么方法可以获取Dart控制台项目的可执行文件吗?

flutter - 又抛出异常: Multiple widgets used the same GlobalKey

java - 如何将点击从 Activity 用户界面传递到 map fragment 以将 map 更改为 MAP_TYPE_HYBRID

google-maps - 访问谷歌地图区域坐标(郊区边界)

flutter - 在 Android 模拟器 Flutter 上构建应用程序时出错

google-maps - 使用 Flutter Google Maps 插件自定义标记