내보내기(0) 인쇄
모두 확장
확장 최소화

VEMap.LatLongToPixel Method

Converts a VELatLong Class object (latitude/longitude pair) to the corresponding pixel on the map.


VEMap.LatLongToPixel(LatLong);

Parameter Description

LatLong

A VELatLong Class object that contains the latitude and longitude of a point

A pixel object of the LatLong point, relative to the current map view.

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

<html>
   <head>
      <title></title>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <script src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=5"></script>
      <script>
         var map = null;
                  
         function GetMap()
         {
            map = new VEMap('myMap');
            latLong = new VELatLong(41.879978158206384, -87.61480808258092);
            map.LoadMap();
            
            map.SetCenterAndZoom(latLong, 15);
            map.SetMapStyle("o");
         }
         function GetInfo()
         {
            if (map.IsBirdseyeAvailable())
            {
                var be = map.GetBirdseyeScene();
                var info = "ID: " + be.GetID() + "\n";
                info += "thumbnail: " + be.GetThumbnailFilename()+ "\n";
                info += "orientation: " + be.GetOrientation()+ "\n";
                info += "height: " + be.GetHeight() + "\n";
                info += "width: " + be.GetWidth() + "\n";
                var pixel = be.LatLongToPixel(map.GetCenter(), map.GetZoomLevel());
                info += "LatLongToPixel: " + pixel.x + ", " + pixel.y + "\n";
                info += "contains pixel: " + be.ContainsPixel(1000,1000,1) + "\n";
                info += "contains latlong: " + be.ContainsLatLong(new VELatLong(35,-100)) + "\n";
                alert(info);
            }
            else
            {
                alert("Bird's eye images are not available at this location and zoom level.");
            }
         }
      </script>
   </head>
   <body onload="GetMap();">
      <div id='myMap' style="position:relative; width:400px; height:400px;"></div>
       <INPUT id="getinfo" type="button" value="Get info about birdseye scene." name="getinfo" 
         onclick="GetInfo();">
   </body>
</html>

표시:
© 2014 Microsoft