VEBirdseyeScene.LatLongToPixel メソッド
VELatLong クラス オブジェクト (緯度/経度ペア) を、マップ上の対応するピクセルに変換します。
構文
VEBirdseyeScene.LatLongToPixel(LatLong, zoomLevel);
パラメータ
パラメータ | 説明 |
---|---|
LatLong |
ポイントの緯度と経度を保持する VELatLong クラス オブジェクトです。このメソッドでは、VEBirdseyeScene.PixelToLatLong メソッドによって暗号化された VELatLong オブジェクトも使用できます。 |
zoomLevel |
現在のマップ ビューのズーム レベルです。 |
戻り値
VELatLong クラス ポイントのピクセル位置です。このオブジェクトのプロパティは x および y の 2 つです。
解説
このメソッドから返されたピクセルの x 軸と y 軸は、概観シーンの左上隅を基点とします。一方、VEMap.LatLongToPixel メソッドは、マップ ビューの左上隅を基点とした x 軸と y 軸を返す点が異なります。
注意
VEMap.LatLongToPixel は、概観図ビューで呼び出すことも可能です。
例
<!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://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.1"></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("現在の位置とズーム レベルでは概観図を表示できません。");
map.AddPushpin(map.GetCenter());
}
}
function AddPin(encLatLong)
{
map.DeleteAllPushpins();
var pin = new VEPushpin(
'mypin',
encLatLong,
null,
'暗号化された位置',
'暗号化された LatLong ポイントにプッシュピンが追加されました。',
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 が true を返しました";
}
else
{
msgTxt = "ContainsPixel が false を返しました";
}
}
else
{
msgTxt = "現在の位置とズーム レベルでは概観図を表示できません。";
}
alert(msgTxt);
}
</script>
</head>
<body onload="GetMap();">
<div id='myMap' style="position:relative; width:400px; height:400px;"></div>
<input id="setpin" type="button" value="プッシュピンを追加" name="setpin"
onclick="SetPin();"><br />
<input id="findvalid" type="button" value="タイルは有効ですか?" name="setpin"
onclick="FindValid();">
</body>
</html>