1

I have a Windows Phone 8.1 XAML app that uses the MapControl to display maps. In the MapControls Loaded event, I set a valid Bing API key

void MyMap_Loaded(object sender, RoutedEventArgs e)
{
    MyMap.MapServiceToken = the key
    MapService.ServiceToken = the key
}

I know the Bing API key is valid because the watermark in the MapControl is not shown.

From the page with the MapControl I navigate to another Page where in the ViewModel I try to find a driving route:

var driving = await MapRouteFinder.GetDrivingRouteAsync(new Geopoint(new BasicGeoposition
{
    Latitude = Latitude,
    Longitude = Longitude
}), Detail.GeneralInfo.GpsCoordinates.Position, MapRouteOptimization.Time);

The problem is that driving.Status is always InvaldiCredentials.

Is there something that I am missing?

The documentation says

Note that you have to provide the authentication token in two separate properties in an app that uses both Map services and the Map control.

and I did this.

The Bing API key I use is generated for Basic / Public Windows Phone App. I also tried to generate one for Basic / Public Windows App, no change.

Igor Kulman
  • 16,211
  • 10
  • 57
  • 118
  • Does the other page also have a map control? – Steve Lillis Nov 20 '14 at 14:54
  • No. I also tried to call `MapRouteFinder.GetDrivingRouteAsync` from the ViewModel for the page with the `MapControl`, same result. – Igor Kulman Nov 20 '14 at 14:55
  • Does it work if you do the whole thing from code instead of a mix of XAML and code? – Steve Lillis Nov 20 '14 at 14:56
  • No, still InvaldiCredentials when calling the code fragment from code behind of the page with the MapControl – Igor Kulman Nov 20 '14 at 15:03
  • In my experience this sort of thing can be down to the difference between live and dev environments. Does this apply to you: https://social.msdn.microsoft.com/Forums/onedrive/en-US/c33be937-59a5-4b30-a9e7-cb2b870f6ed9/bing-map-control-invalid-credentials-when-connecting-to-staging?forum=vemapcontroldev. Other than that, I'm pretty much out of ideas :) – Steve Lillis Nov 20 '14 at 15:05
  • Someone here (http://stackoverflow.com/questions/5283310/wp7-bing-maps-invalid-credentials-error) got the key again and applied it and it miraculously worked. Could be worth a shot. – Steve Lillis Nov 20 '14 at 15:06

1 Answers1

0

I have a working app that uses this token. I only set it to a Map control in XAML, and then I can use both the Map and the MapService, apparently.

My Maps key token is 22 characters long. The only way to get it is, AFAIK

  • Make an app
  • Upload it to the store but do not submit
  • You app gets associated with a store ID and you will see a map token
  • THAT is the token you will need

See screenshot. Is that the procedure you followed?

screenshot from dev center

Also, make sure xmlns:Maps="using:Windows.UI.Xaml.Controls.Maps", not the old Bing control. Don't even know if the old control is still available in the Universal Apps btw

Community
  • 1
  • 1
LocalJoost
  • 415
  • 3
  • 7
  • I had to manually edit the Package.appxmanifest file to make all the guids match and then it started to work, thanks! – Igor Kulman Nov 20 '14 at 21:31
  • That is odd. Usually the project/store menu option takes care of that. Make sure you don't re-use other apps' ids or you will run into funky problems when you submit. – LocalJoost Nov 28 '14 at 11:10