To access the Bing Maps Silverlight Control and the functionality that it provides, you need a Bing Maps Key.
Create a Bing Maps Developer Account
To get a Bing Maps Key to use in your application, you first need to create a Bing Maps Developer Account.
- Go to the Bing Maps Account Center at https://www.bingmapsportal.com and click the Create an account link.
- Sign in using your Windows Live ID. If you do not have a Windows Live ID, you can get one at https://www.bingmapsportal.com/SignIn/Logon.
- Once you have signed in using a valid Windows Live ID, you are asked to provide the following items:
- Account name Required. A friendly name that you and Microsoft can use to identify your account. You can also reference the unique ID that is assigned when your account is created.
- Contact name The name of the developer account owner. Alternatively, this is the name of someone that can be contacted when questions about this developer account arise.
- Company name The name of the company using this developer account.
- Email address Required. An email address which should be used to communicate with the developer account owner. This address can be the Windows Live ID used to login to the Bing Maps Account Center.
- Phone number A phone number that can be used in communications about this developer account.
- API terms of use Required. Review the terms of use and check the box to accept them.
Tip: |
|---|
| You can update your Bing Maps Developer Account information any time by clicking the Update or view account details link. |
Once you have created a Bing Maps Developer Account, you can create up to five Bing Maps Keys for use in your Bing Maps applications.
- On the Bing Maps Account Center left-hand navigation pane, click Create or view keys.
- If you have never created any keys, the list of available keys will be empty. To create a new key, enter the name of your application and the URL which corresponds to the website where the key will be used. Then click the Create key button. The page is updated and the new key is added to the list of available keys.
Important: |
|---|
| You can create up to five Bing Maps Keys. |
Use the Bing Maps Key in Your Application
After you have created a Bing Maps Developer Account, available Bing Maps Keys appear in the Bing Maps Account Center. Click the Create or view keys link to view them. Copy the key associated with the Web site URL which corresponds to the application you are building and assign this string value to the ApplicationId property of an ApplicationIdCredentialsProvider object. Use this object to set the CredentialsProvider property of the MapBase class. Or alternatively, you can just set the CredentialsProvider attribute of your map element in XAML as shown in the example below.
<UserControl x:Class="SilverlightApplication1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:m="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl"
Width="1024" Height="768">
<Grid x:Name="LayoutRoot" Background="White">
<m:Map x:Name="myMap" CredentialsProvider="Your key" Mode="Road"/>
</Grid>
</UserControl>
When the Bing Maps Silverlight Control is loaded with a valid Bing Maps Key, Bing Maps counts sessions. A session begins with the load of the Bing Maps Silverlight Control into a user’s browser and includes all Bing Maps Silverlight Control interactions until the browser is closed or the user moves to a different page.