Share via


VEShape.GetID メソッド

VEShape オブジェクトの内部識別子を取得します。

構文

VEShape.GetID();

戻り値

VEShape オブジェクトの内部識別子を表す String オブジェクトです。

戻り値

この識別子は、VEShape オブジェクト イベントを処理する際に使用します。VEShape オブジェクトに識別子が割り当てられるのは、それがレイヤに追加された場合のみです。レイヤの一部になっていない VEShape オブジェクトの識別子を取得しようとすると、VEShape.GetID メソッドから null が返されます。

<!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 lat1 = 44.88980971906551; 
var lon1 = -85.39827346801759;
var lat2 = 44.99879594361408; 
var lon2 = -85.70159912109375;
var latLong1 = new VELatLong(lat1, lon1);
var latLong2 = new VELatLong(lat2, lon2);
var latLong3 = new VELatLong(45.004622150149935, -85.56427001953126);
        
// 多角形のシェイプを形成する VELatLong 配列のペアを作成します
var points01 = [
new VELatLong(lat1, lon1 - 0.15),
new VELatLong(lat1 + 0.1, lon1 - 0.05),
new VELatLong(lat1 + 0.1, lon1 + 0.05),
new VELatLong(lat1, lon1 + 0.15),
new VELatLong(lat1 - 0.1, lon1 + 0.05),
new VELatLong(lat1 - 0.1, lon1 - 0.05)];
            
var points02 = [
new VELatLong(lat2, lon2 - 0.15),
new VELatLong(lat2 + 0.1, lon2 - 0.05),
new VELatLong(lat2 + 0.1, lon2 + 0.05),
new VELatLong(lat2, lon2 + 0.15),
new VELatLong(lat2 - 0.1, lon2 + 0.05),
new VELatLong(lat2 - 0.1, lon2 - 0.05)];
 
function GetMap()
         {
map = new VEMap('myMap');
map.LoadMap();

map.SetCenterAndZoom(latLong3, 9);
map.SetMapStyle(VEMapStyle.Aerial);      
map.AttachEvent("onclick", ShapeInfo);
AddShapes();
         }   
     
function AddShapes()
         {   
//VEShape オブジェクトを作成し、パラメータを設定してマップに追加します         
shape01 = new VEShape(VEShapeType.Polygon, points01);            
shape01.SetLineWidth(2);
shape01.SetLineColor(new VEColor(0,150,100,1.0));
shape01.SetFillColor(new VEColor(0,100,150,0.5));
shape01.SetTitle("shape01 のタイトル");
shape01.SetDescription("これは shape01 の説明です。");
shape01.SetMoreInfoURL("https://msdn.microsoft.com");
shape01.SetPhotoURL("http://dev.live.com/Themes/default/images/Mix08/service/logo_virtualearth.jpg");
shape01.SetPoints(points01);
shape01.ShowIcon();
map.AddShape(shape01);
            
shape02 = new VEShape(VEShapeType.Polygon, points02);            
shape02.SetLineWidth(2);
shape02.SetLineColor(new VEColor(0,100,150,1.0));
shape02.SetFillColor(new VEColor(0,150,100,0.5));
shape02.SetTitle("shape02 のタイトル");
shape02.SetDescription("これは shape02 の説明です。");
shape02.SetMoreInfoURL("https://msdn.microsoft.com");
shape02.SetPhotoURL("http://dev.live.com/Themes/default/images/Mix08/service/logo_virtualearth.jpg");
shape02.SetPoints(points02);
shape02.ShowIcon();
map.AddShape(shape02);
         }
        
function SwapPoints()
         {
//2 つのシェイプの間でポイントを切り替えて両者を入れ替えます
var pts = shape01.GetPoints();

if (pts[0].Latitude == "44.88980971906551")
            {
shape01.SetPoints(points02);
shape02.SetPoints(points01);
            }
else
            {
shape01.SetPoints(points01);
shape02.SetPoints(points02);
            }
         }
        
function ShapeInfo(e)
         {
if(e.elementID != null)
            {
shape = map.GetShapeByID(e.elementID);
var info = "";
info += "ID (イベント オブジェクト):" + e.elementID + "<br />";
info += "ID (GetID メソッド):" + shape.GetID() + "<br />";
info += "タイプ:" + shape.GetType() + "<br />";
info += "タイトル:" + shape.GetTitle() + "<br />";
info += "説明:" + shape.GetDescription() + "<br />";
info += "詳細情報 URL:" + shape.GetMoreInfoURL() + "<br />";
info += "画像 URL:" + shape.GetPhotoURL() + "<br />";
             
fillColor = shape.GetFillColor();
info += "塗りつぶしの色:R:" + fillColor.R +
" | G:" + fillColor.G +
" | B:" + fillColor.B +
" | A:" + fillColor.A +
"<br />";
          
lineColor = shape.GetLineColor();  
info += "線の色:R:" + lineColor.R +
" | G:" + lineColor.G +
" | B:" + lineColor.B +
" | A:" + lineColor.A + "<br />"; 
             
info += "線の幅:" + shape.GetLineWidth() + "<br />";

label.innerHTML = info;
            }
else
            {
label.innerText = "";
            }
         }
</script>
</head>
<body onload="GetMap();" style="font-family:MS PGothic">
<div id='myMap' style="position:relative; width:400px; height:400px;"></div>
<a href='#' onclick="SwapPoints()">ポイントの切り替え</a><br />
詳しい情報を表示するにはシェイプをクリックしてください。<br />
<div id="label"></div>
</body>
</html>