首页 > 解决方案 > 如何在 Xamarin.Android 中更新 Maps SDK(版本 18.0)?

问题描述

我是 Xamarin.Android 的新手。我正在尝试更新适用于 Android 的 Google Maps SDK(版本 18.0.0),现在可通过 Google Play 服务获得。但是,有关更新的所有文档都使用 build.gradle 并将依赖项更改为com.google.android.gms:play-services-maps:18.0.0Xamarin 没有的依赖项。如何在 Xamarin 中更新 Maps SDK?

标签: c#androidvisual-studiomobilexamarin.android

解决方案


Xamarin 为 Google Play 服务创建和维护 Xamarin.Android 绑定 Google 还为 Android 提供了本机映射 API。Maps API 适用于您希望更好地控制地图体验的情况。Maps API 可以实现的功能包括:

  • 以编程方式更改地图的视点。
  • 添加和自定义标记。
  • 使用叠加层注释地图。

与现已弃用的 Google Maps Android API v1 不同,Google Maps Android API v2 是Google Play Services的一部分。Xamarin.Android 应用必须满足一些强制性先决条件才能使用 Google Maps Android API。

在使用 Maps API 之前需要执行几个步骤,包括:

  • 获取 Maps API 密钥

  • 安装 Google Play 服务 SDK

  • 从 NuGet 安装 Xamarin.GooglePlayServices.Maps 包

  • 指定所需的权限

  • (可选)使用 Google API 创建模拟器

有关更多详细信息,您可以查看:

https://docs.microsoft.com/en-us/xamarin/android/platform/maps-and-location/maps/maps-api#install-gps-sdk

https://github.com/xamarin/GooglePlayServicesComponents


推荐阅读