tixovoxi tixovoxi - 1 month ago 11
C# Question

How to get localized MapLocation in UWP?

I'm using a simple method that returns map location for me, but I would like to get that address in english only.

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;
}


My problem is: When my windows language is russian it returns cirillic characters.

I have tried to override the application language:

ApplicationLanguages.PrimaryLanguageOverride = "en";


But it seems it doesn't works...

How could i get the localized string from this method?

Answer

MapLocationFinder.FindLocationsAtAsync method does not provide a mechanism to specify the language used in the returned address now. It always automatically uses the Windows display language. And in most cases, the Street and Town are localized to its local culture. For example, if you request a location in France, the street names are localized in French.

As a workaround, we can use Bing Maps REST Services which provides REST APIs that can specify Culture Parameter. For FindLocationsAtAsync method, we can use Find a Location by Point like following:

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

Also, you are welcome to submit a feature request on WPDev User Voice to ask for this feature.