Use the Bing Maps Account Center to register your Bing Maps AJAX Control application.
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 use this string value in the VEMap.SetCredentials Method as shown in the example below.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>SetCredentials</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?
v=6.2"></script>
<script type="text/javascript">
var map = null;
function GetMap()
{
map = new VEMap('myMap');
map.AttachEvent("oncredentialserror", MyHandleCredentialsError);
map.AttachEvent("oncredentialsvalid", MyHandleCredentialsValid);
map.SetCredentials("Bing Maps Key");
map.LoadMap();
}
function MyHandleCredentialsError()
{
alert("The credentials are invalid.");
}
function MyHandleCredentialsValid()
{
alert("The credentials are valid.");
}
</script>
</head>
<body onload="GetMap();">
<div id='myMap' style="position:relative; width:600px; height:400px;"></div>
</body>
</html>
When the Bing Maps AJAX Control is loaded with a valid Bing Maps Key, Bing Maps counts sessions. A session begins with the load of the Bing Maps AJAX Control into a user’s browser and includes all Bing Maps AJAX Control interactions until the browser is closed or the user moves to a different page.
Reference
VEMap.SetCredentials Method
VEMap.oncredentialserror Event
VEMap.oncredentialsvalid Event