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

Changes the map view so that it includes both the specified VELatLong Class point and the center point of the current map.



Parameter Description


A VELatLong Class object that specifies the latitude and longitude of the point to include

When you call the IncludePointInView method, the center point of the map changes, but the original center point remains within the map view.

<!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');

            var center = map.GetCenter();
            map.AttachEvent("onclick", GetLatLong);
         function IncludePoint()
            var latLong = new VELatLong(parseFloat(document.getElementById('txtLat').value), parseFloat(document.getElementById('txtLong').value));

            var myPin = new VEShape(VEShapeType.Pushpin, latLong);
         function GetLatLong(e)
            var x = e.mapX;
            var y = e.mapY;
            pixel = new VEPixel(x, y);
            var LL = map.PixelToLatLong(pixel);
            document.getElementById('txtLat').value = LL.Latitude;
            document.getElementById('txtLong').value = LL.Longitude;
   <body onload="GetMap();" style="font-family:Arial">
      <div id='myMap' style="position:relative; width:400px; height:400px;"></div>
      Click the map to change the Lat/Long coordinate values.
      <br />
      <a href='#' onclick="IncludePoint()">Include Point in View</a>
      <br />
      Lat: <input id="txtLat" value="42.14188805833658" />
      <br />
      Lon: <input id="txtLong" value="-102.85869240760804" />