MSDN Library

VEMap.LatLongToPixel Method

You are not viewing the latest version of the AJAX control. Bing Maps AJAX V7 is the recommended JavaScript control for Bing Maps. If you need this documentation, it is available in as a CHM or PDF download.

Converts VELatLong Class objects (latitude/longitude pair) to VEPixel Class objects.

VEMap.LatLongToPixel(latLongArray, zoomLevel, callback);


Parameter Description


A VELatLong object or an array of VELatLong objects. Required. If an array is passed, the callback parameter must be specified.


The zoom level at which the VELatLong objects are converted to VEPixel objects. Optional. If this parameter is not supplied, the current zoom level is used.


The name of the function called with the array of corresponding VEPixel objects. Optional.

If the callback parameter is not supplied, the LatLongToPixel method returns a VEPixel object corresponding to the VELatLong object specified in the latLongArray parameter.

If the callback parameter is supplied, the specified callback function must accept an array of VEPixel objects.

To get the latitude and longitude of a point on the map, use the VEMap.PixelToLatLong Method.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

      <script type="text/javascript" src=""></script>

      <script type="text/javascript">
         var map = null;

         function GetMap()
            map = new VEMap('myMap');
            map.LoadMap(new VELatLong(47.62165, -122.3492), 18);

         function GetPixel()
            var info = "";

            // Get pixel info about center of the map
            var pixel = map.LatLongToPixel(map.GetCenter(), map.GetZoomLevel());

            info += "Map center pixel coordinates are : (" + pixel.x + ", " + pixel.y + ")\n\n";


   <body onload="GetMap();">
      <div id='myMap' style="position:relative; width:600px; height:400px;"></div>
      <input id="getpixel" type="button" value="Get the pixel of the center of the map" name="getpixel" onclick="GetPixel();">

© 2015 Microsoft