Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

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.


VEMap.IncludePointInView(latlong);

Parameters

Parameter Description

latlong

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" "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=6.3"></script>

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

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

            var myPin = new VEShape(VEShapeType.Pushpin, latLong);
            map.AddShape(myPin);
         }
     
         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;
         }
      </script>
   </head>
   <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" />
   </body>
</html>

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