VEMap.SetClientToken Method
Note: |
|---|
|
This method is deprecated and should no longer be used. Please use the VEMap.SetCredentials Method with your Bing Maps Key for authentication.
|
Sets a Bing Maps token for the VEMap object.
VEMap.SetClientToken(clientToken);
Parameters
| Parameter | Description |
|---|---|
clientToken | A string representing the Bing Maps token. |
This method is deprecated and should no longer be used. Please use the VEMap.SetCredentials Method with your Bing Maps Key for authentication.
The SetClientToken method is used to help Bing Maps customers monitor their map control usage. By setting a token on the VEMap object, requests made to Bing Maps by the map control can be tracked. More information is found in the Tracking Your Bing Maps Usage topic.
Use the SetClientToken method to set a token before calling the VEMap.LoadMap Method to ensure all map control and tile requests are tracked.
If an invalid token is set, the VEMap.ontokenerror Event fires when the map control makes a request to Bing Maps.
If an expired token is set, the VEMap.ontokenexpire Event fires when the map control makes a request to Bing Maps.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>SetClientToken</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.3"></script> <script type="text/javascript"> var map = null; function GetMap() { map = new VEMap('myMap'); map.AttachEvent("ontokenerror", MyHandleTokenError); map.AttachEvent("ontokenexpire", MyHandleTokenExpire); } function SetToken() { map.SetClientToken(document.getElementById('txtToken').value); alert("Token is set: " + document.getElementById('txtToken').value); } function LoadMap() { map.LoadMap(); var location = new VELatLong(47.65, -122.2); map.SetCenterAndZoom(location, 18); MakeBirdseyeRequest(); } function MyHandleTokenError() { alert("Token is invalid."); } function MyHandleTokenExpire() { alert("Token has expired."); } function MakeBirdseyeRequest() { map.SetMapStyle(VEMapStyle.Birdseye); } </script> </head> <body onload="GetMap();"> <input type="text" name="txtToken" value="TokenGoesHere"/> <input type="button" value="SetClientToken" onclick="SetToken();"/><br> <input type="button" value="Load the map after a token is set." onclick="LoadMap()";/> <div id='myMap' style="position:relative; width:600px; height:400px;"></div> </body> </html>
Note: