VEBirdseyeScene.PixelToLatLong 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 a point in the bird's eye scene to an encrypted latitude/longitude value.
VEBirdseyeScene.PixelToLatLong(pixel, zoomLevel);
Parameters
Parameter | Description |
---|---|
pixel |
A VEPixel Class object representing a pixel location on the map |
zoomLevel |
The zoom level of the current map view |
Return Value
An encrypted VELatLong object.
Remarks
You cannot retrieve the unencrypted latitude and longitude of a specific point in a bird's eye image. The return value is an encrypted VELatLong, but you can use it by passing it back to other methods. For example, you can use the encrypted VELatLong as input for the VEMap.GetRoute Method, the VEMap.SetCenter Method, and the VEMap.SetCenterAndZoom Method.
Example
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://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="https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.3"></script>
<script type="text/javascript">
var map = null;
var be = null;
var pixel = null;
var encLatLong = null;
function GetMap()
{
map = new VEMap('myMap');
map.LoadMap(new VELatLong(47.7,-122.2),14);
map.SetZoomLevel(15);
SetPin();
}
function SetPin()
{
if (map.IsBirdseyeAvailable())
{
be = map.GetBirdseyeScene();
pixel = be.LatLongToPixel(map.GetCenter(), map.GetZoomLevel());
encLatLong = be.PixelToLatLong(pixel, map.GetZoomLevel());
AddPin(encLatLong);
}
else
{
alert("Bird's eye images are not available at this location and zoom level.");
map.AddPushpin(map.GetCenter());
}
}
function AddPin(encLatLong)
{
map.DeleteAllPushpins();
var pin = new VEPushpin(
'mypin',
encLatLong,
null,
'Encrypted Location',
'Pushpin added to encrypted LatLong point.',
null,
null,
null);
map.AddPushpin(pin);
}
function FindValid()
{
var msgTxt = "";
be = map.GetBirdseyeScene();
if (be != null)
{
pixel = be.LatLongToPixel(map.GetCenter(), map.GetZoomLevel());
encLatLong = be.PixelToLatLong(pixel, map.GetZoomLevel());
if (be.ContainsPixel(encLatLong.x, encLatLong.y, map.GetZoomLevel))
{
msgTxt = "ContainsPixel has returned true";
}
else
{
msgTxt = "ContainsPixel has returned false";
}
}
else
{
msgTxt = "Bird's eye images are not available at this location and zoom level.";
}
alert(msgTxt);
}
</script>
</head>
<body onload="GetMap();">
<div id='myMap' style="position:relative; width:400px; height:400px;"></div>
<input id="setpin" type="button" value="Add Pushpin" name="setpin"
onclick="SetPin();"><br />
<input id="findvalid" type="button" value="Is Tile Valid?" name="setpin"
onclick="FindValid();">
</body>
</html>