Request a maps authentication key
Online maps services may not be available on older versions of Windows 10. On the following versions, MapControl may no longer display maps and APIs in the Windows.Services.Maps namespace may not return results:
- Windows 10, version 1607 and earlier versions: map services will be unavailable worldwide starting in October 2020
- Windows 10, version 1703 and earlier versions: map services are unavailable on some devices sold in China
Your Universal Windows app must be authenticated before it can use the MapControl and map services in the Windows.Services.Maps namespace. To authenticate your app, you must specify a maps authentication key. This topic describes how to request a maps authentication key from the Bing Maps Developer Center and add it to your app.
Tip To learn more about using maps in your app, download the following sample from the Windows-universal-samples repo on GitHub:
Get a key
Create and manage map authentication keys for your Universal Windows apps using the Bing Maps Developer Center.
To create a new key
In your browser, navigate to the Bing Maps Developer Center (https://www.bingmapsportal.com).
If you are asked to sign in, enter your Microsoft account and click Sign in.
Choose the account to associate with your Bing Maps account. If you want to use your Microsoft account, click Yes. Otherwise, click Sign in with another account.
Under the My account menu, click My Keys.
If you have previously created a key, click on the link to create a new key. Otherwise proceed to the Create Key form.
Complete the Create Key form and then click Create.
- Application name: The name of your application.
- Application URL (optional): The URL of your application.
- Key type: Select Basic or Enterprise.
- Application type: Select Windows Application for use in your Universal Windows app.
This is an example of what the form looks like.
After you click Create, the new key appears below the Create Key form. Copy it to a safe place or immediately add it to your app, as described in the next step.
Add the key to your app
To add the key to a map control
To authenticate the MapControl, set the MapServiceToken property to the authentication key value. You can set this property in code or in XAML markup, depending on your preferences. For more info about using the MapControl, see Display maps with 2D, 3D, and Streetside views.
This example sets the MapServiceToken to the value of the authentication key in code.
MapControl1.MapServiceToken = "abcdef-abcdefghijklmno";
This example sets the MapServiceToken to the value of the authentication key in XAML markup.
<Maps:MapControl x:Name="MapControl1" MapServiceToken="abcdef-abcdefghijklmno"/>
To add the key to map services
To use services in the Windows.Services.Maps namespace, set the ServiceToken property to the authentication key value. For more info about using map services, see Display routes and directions and Perform geocoding and reverse geocoding.
This example sets the ServiceToken to the value of the authentication key in code.
MapService.ServiceToken = "abcdef-abcdefghijklmno";