Export (0) Print
Expand All
3 out of 5 rated this helpful - Rate this topic

VEMap.PanToLatLong 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.

Pans the map to a specific latitude and longitude.



Parameter Description


A VELatLong Class object that represents the latitude and longitude of the point on which to center the map

The PanToLatLong method moves the map from one location to another with a smooth transition effect. If you want the map to instantly reposition on a new center point, use the VEMap.SetCenter Method.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <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');

         function PanXY()
            if ((document.getElementById('txtX').value != "" && document.getElementById('txtY').value != "") && (!isNaN(document.getElementById('txtX').value) && !isNaN(document.getElementById('txtY').value)))
               map.Pan(document.getElementById('txtX').value, document.getElementById('txtY').value);
               alert("Please enter a valid numeric value.");
         function PanLL()
            if ((document.getElementById('txtLat').value != "" && document.getElementById('txtLong').value != "") && (!isNaN(document.getElementById('txtLat').value) && !isNaN(document.getElementById('txtLong').value)))
               var latLong = new VELatLong(document.getElementById('txtLat').value, document.getElementById('txtLong').value);
               alert("Please enter a valid Latitude or Longitude value.");
   <body onload="GetMap();" style="font-family: Arial">
      <div id='myMap' style="position: relative; width: 400px; height: 400px;">
      Pixels X:
      <input id="txtX" style="width: 50px" value="100" />&nbsp;&nbsp;|&nbsp;&nbsp; Pixels
      <input id="txtY" style="width: 50px" value="100" />&nbsp;&nbsp;
      <input id="btnPanXY" type="button" value="Pan to X/Y" name="btnPanXY" onclick="PanXY()" />
      <br />
      <input id="txtLat" value="41.677014822032184" />&nbsp;&nbsp;|&nbsp;&nbsp; Long:
      <input id="txtLong" value="-83.5400390625" />&nbsp;&nbsp;
      <input id="btnPanLL" type="button" value="Pan to Lat/Long" name="btnPanLL" onclick="PanLL()" />

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft. All rights reserved.