【问题标题】:How to get localized MapLocation in UWP?如何在 UWP 中获取本地化的 MapLocation?
【发布时间】:2016-10-05 18:07:32
【问题描述】:

我正在使用一种简单的方法为我返回地图位置,但我想只获取英文地址。

public static async Task<MapLocation> ResolveLocationForGeopoint(Geopoint geopoint)
{
    MapLocationFinderResult result = await MapLocationFinder.FindLocationsAtAsync(geopoint);

    if (result.Status == MapLocationFinderStatus.Success)
    {
        if (result.Locations.Count != 0)
            // Check if the result is really valid
            if (result.Locations[0].Address.Town != "")
                return result.Locations[0];
    }
    return null;
}

我的问题是:当我的 windows 语言是俄语时,它返回 cirillic 字符。

我已尝试覆盖应用程序语言:

ApplicationLanguages.PrimaryLanguageOverride = "en";

但是好像不行……

我怎样才能从这个方法中得到本地化的字符串?

【问题讨论】:

  • 可能城市名称或位置是西里尔字符,为什么要更改?
  • 因为我使用的是匈牙利的地图,而且任何匈牙利城市名称中都没有西里尔字符。 :D 它只显示系统语言中的每个名称。

标签: c# uwp bing-maps uwp-maps


【解决方案1】:

MapLocationFinder.FindLocationsAtAsync 方法现在不提供指定返回地址中使用的语言的机制。它始终自动使用 Windows 显示语言。在大多数情况下,StreetTown 都本地化为当地文化。例如,如果您请求法国的位置,则街道名称将本地化为法语。

作为一种解决方法,我们可以使用Bing Maps REST Services,它提供了可以指定Culture Parameter 的REST API。对于FindLocationsAtAsync 方法,我们可以使用Find a Location by Point,如下所示:

http://dev.virtualearth.net/REST/v1/Locations/47.64054,-122.12934?c=en-US&key=BingMapsKey

另外,欢迎您在WPDev User Voice 上提交功能请求以请求此功能。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-02-20
    • 1970-01-01
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-28
    相关资源
    最近更新 更多