Expand Minimize
6 out of 11 rated this helpful - Rate this topic

VEMap.SetCredentials Method

Bing Services

Sets the credentials to use to authenticate map service requests.

Ee692182.note(en-us,MSDN.10).gifNote:
Use the SetCredentials method to set the Bing Maps Key that you obtained from the Bing Maps Account Center as described in the Getting Started with the Bing Maps AJAX Control topic. Information about Bing Maps usage reports is in Viewing Bing Maps Usage Reports.

VEMap.SetCredentials(credentials);

Parameters

Parameter Description

credentials

A string that is the Bing Maps Key to set.

<!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.3"></script>

      <script type="text/javascript">
         var map     = null;
         
         function GetMap()
         {
            map = new VEMap('myMap');

            var mykey = "Bing Maps Key";
            map.SetCredentials(mykey);

            // Attach the credentials events
            map.AttachEvent("oncredentialserror", MyHandleCredentialsError);
            map.AttachEvent("oncredentialsvalid", MyHandleCredentialsValid);   
           
            LoadMap();
         
         }


         function LoadMap()
         {
            map.LoadMap();

            var location = new VELatLong(47.65, -122.2);
            map.SetCenterAndZoom(location, 18);

         }

         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>

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.