VEMap.IncludePointInView メソッド
指定された VELatLong クラスのポイントと、現在のマップの中心点の両方を含むようにマップ ビューを変更します。
構文
VEMap.IncludePointInView(latlong);
パラメータ
パラメータ | 説明 |
---|---|
latlong |
含めるポイントの緯度と経度を指定する VELatLong クラス オブジェクトです。 |
解説
IncludePointInView メソッドを呼び出すとマップの中心点は変更されますが、元の中心点も引き続きマップ ビュー内に表示されます。
例
<!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;
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(txtLat.value), parseFloat(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);
txtLat.value = LL.Latitude;
txtLong.value = LL.Longitude;
}
</script>
</head>
<body onload="GetMap();" style="font-family:MS PGothic">
<div id='myMap' style="position:relative; width:400px; height:400px;"></div>
マップをクリックすると、緯度/経度の座標値が変更されます。
<br />
<a href='#' onclick="IncludePoint()">ビュー内にポイントを含める</a>
<br />
緯度:<input id="txtLat" value="42.14188805833658" />
<br />
経度:<input id="txtLong" value="-102.85869240760804" />
</body>
</html>