【问题标题】:How to use Dark Mode Google Maps in Xamarin.Forms.Maps?如何在 Xamarin.Forms.Maps 中使用暗模式谷歌地图?
【发布时间】:2021-08-24 03:26:27
【问题描述】:

我正在尝试使用 Xamarin.Forms.Maps nuget 包在我的 Xamarin.Forms 应用中使用暗模式 Google 地图。

使用 OnElementChanged if(e.NewElement != null) 方法的 CustomRenderer 中的这行代码,我已经成功地在 iOS 地图上设置了深色模式:

nativeMap.OverrideUserInterfaceStyle= UIUserInterfaceStyle.Dark;

但是我无法在 Google 地图上使用它,我想知道是否有任何方法可以得到相同的结果并在 Android 上使用暗模式 Google 地图。

感谢您的帮助

【问题讨论】:

  • 关于谷歌地图样式,我找了一个帖子你可以看看:stackoverflow.com/questions/52830934/…
  • @CherryBu-MSFT 谢谢!但是,这不起作用,因为我正在使用 Xamarin.Forms.Maps,它建议使用 Xamarin.Forms.GoogleMaps 这似乎是一个不适用于新版本 Xamarin 的包

标签: c# google-maps xamarin.forms xamarin.forms.maps


【解决方案1】:

在 xamarin.android 中创建一个原始文件夹并添加包含主题的 json 文件,然后编写此代码及其工作。 NativeMap.SetMapStyle(MapStyleOptions.LoadRawResourceStyle(this.Context, Resource.Raw.map_style_night));

【讨论】:

    【解决方案2】:

    还有其他人可以帮忙吗?我们可以做些什么来在不使用 Xamarin.Forms.GoogleMaps 的情况下在 Google Maps 中获取 Dark Mode 地图,因为这个包似乎不适用于 Xamarin 上的新版本?

    【讨论】:

    • 使用 xamarin.forms.maps
    猜你喜欢
    • 2020-01-26
    • 1970-01-01
    • 1970-01-01
    • 2013-03-21
    • 2021-11-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多