Export (0) Print
Expand All

PositionOptions Object

Bing

Contains options for the getCurrentPosition method of the GeoLocationProvider class.

Properties

Name Type Description

enableHighAccuracy

boolean

A boolean indicating whether only a high accuracy result should be retrieved. The default value is false. Setting this property to true may result in a slower response time.

errorCallback

function

The function to call when an error occurs during the user location request. The callback function must accept one argument. The argument object contains two properties, internalError, a PositionError type, and errorCode, a number.

Any one of the following errorCode values may be returned:

  • 1 The application origin does not have permission to use the GeoLocation API.

  • 2 The position of the user could not be determined because of a device failure.

  • 3 The time specified in timeout has been exceeded.

  • 4 A request is already in process.

  • 5 The user’s browser does not support geo location.

maximumAge

number

A number indicating the acceptable age, in milliseconds, of a cached geo location result to return. The default value is 0, which indicates a new (not cached) result will be retrieved.

showAccuracyCircle

boolean

A boolean indicating whether to display the polygon on the map that shows the accuracy of the returned geo location. The default value is true.

successCallback

function

The function to call when the user’s location was successfully retrieved. The callback function must accept one argument. The argument object contains two properties, center, a Location type, and position, a Position type.

timeout

number

The length of time, in milliseconds, to allow for the geo location request to return. By default there is no timeout.

updateMapView

boolean

A boolean indicating whether to update the map view with the best view of the user’s location (if the request is successful). The default value is true.

Example

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
   <head>
      <title></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=7.0"></script>

      <script type="text/javascript">

         var map;
         
         function GetMap()
         {
            
            // Set the map options
            var mapOptions = {credentials:"Bing Maps Key"};


            // Initialize the map
            map = new Microsoft.Maps.Map(document.getElementById("mapDiv"), mapOptions);

            // Initialize the location provider
            var geoLocationProvider = new Microsoft.Maps.GeoLocationProvider(map);

            // Get the user's current location
            geoLocationProvider.getCurrentPosition({successCallback:displayCenter});
          

         }

         function displayCenter(args)
         {
            // Display the user location when the geo location request returns
            alert("The user's location is " + args.center);
         }


      </script>
   </head>
   <body onload="GetMap();">
      <div id='mapDiv' style="position:relative; width:400px; height:400px;"></div>       
   </body>
</html>
Show:
© 2014 Microsoft