【问题标题】:Flutter: How to display location layer in Google MapFlutter:如何在谷歌地图中显示位置图层
【发布时间】:2019-05-18 19:25:04
【问题描述】:

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

this 等问题似乎表明可能需要其他依赖项才能显示 Google 地图位置图层。但是,我不认为是这种情况。

我目前的方法是否遗漏了某些东西,还是需要额外的依赖?

我在我的 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>

地图代码:

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

【问题讨论】:

    标签: google-maps dart flutter


    【解决方案1】:

    你应该相信这种情况:)

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

    Geolocator Plugin to get current location

    【讨论】:

    • 谢谢,mathronaut。正如您所建议的,我能够请求使用位置包的许可。我只是认为这应该由 google_maps_flutter 包本身来处理,而不需要额外的依赖。
    猜你喜欢
    • 2019-06-22
    • 1970-01-01
    • 1970-01-01
    • 2015-05-11
    • 1970-01-01
    • 1970-01-01
    • 2019-08-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多