Search code examples
c#xamluwpwindows-mobileuwp-maps

Invalid Credentials on MapLocationFinderResult uwp c#


I am having a strange problem with the use of MapLocationFinder.

I am using MapLocationFinder to retrieve longitude and latitude based on string address:

string address = ""; // Any address here

var locFinderResult = await MapLocationFinder.FindLocationsAsync(address, new Geopoint(new BasicGeoposition()));

After this, I use Laucher to start "drive to" application and get navigation map:

var geoPos = locFinderResult.Locations[0].Point.Position;

var url = $"ms-drive-to:?destination.latitude={geoPos.Latitude.ToString(CultureInfo.InvariantCulture)}&destination.longitude={geoPos.Longitude.ToString(CultureInfo.InvariantCulture)}&destination.name={address}";
var driveToUri = new Uri(url);

await Launcher.LaunchUriAsync(driveToUri);

Up until recently this worked just fine on all devices. I was not required any token or anything, since I am not implementing Map control in XAML. However, a couple days ago I started receiving "InvalidCredentials" response for locFinderResult. It still works on only one device. I have never used any credentials so I don't know why it only works on this one.

Does anyone knows what could cause this issue?


Solution

  • It looks like from some recent time Microsoft requires you to get the key from the Bing Maps Developers Center to use this functionality. See, the instructions: https://learn.microsoft.com/en-us/windows/uwp/maps-and-location/authentication-key