VEMap.DeleteShape メソッド
ベース マップ レイヤなどのレイヤから 1 つの VEShape クラス オブジェクトを削除します。
構文
VEMap.DeleteShape(shape);
パラメータ
パラメータ | 説明 |
---|---|
shape |
削除する VEShape クラス オブジェクトです (必須)。 |
解説
VEShape オブジェクトは、プッシュピン、折れ線、または多角形の場合があります。
例
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>VEMap.AddShape, VEMap.DeleteShape, VEMap.Clear, VEShape.Hide, VEShape.Show</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 shape = null;
var c1Shape = null;
var c2Shape = null;
var c3Shape = null;
var c4Shape = null;
var cornerOne = new VELatLong(45.01188,-111.06687);
var cornerTwo = new VELatLong(45.01534,-104.06324);
var cornerThree = new VELatLong(41.01929,-104.06);
var cornerFour = new VELatLong(41.003,-111.05878);
function GetMap()
{
map = new VEMap('myMap');
map.LoadMap();
// ボタンの初期状態を設定します。
btnDeleteShape.disabled = "disabled";
btnAddShape.disabled = 0;
btnHideShape.disabled = "disabled";
btnShowShape.disabled = "disabled";
}
function AddShape()
{
// 各コーナーにプッシュピンを作成します。
c1Shape = new VEShape(VEShapeType.Pushpin, cornerOne);
c2Shape = new VEShape(VEShapeType.Pushpin, cornerTwo);
c3Shape = new VEShape(VEShapeType.Pushpin, cornerThree);
c4Shape = new VEShape(VEShapeType.Pushpin, cornerFour);
// VEShape オブジェクトを作成してパラメータを割り当てます。
var points = new Array(cornerOne, cornerTwo, cornerThree, cornerFour);
shape = new VEShape(VEShapeType.Polygon, points);
shape.SetLineWidth(3);
shape.SetLineColor(new VEColor(0,150,100,1.0));
shape.SetFillColor(new VEColor(0,150,100,0.5));
// マップにシェイプを追加します。
map.AddShape(shape);
map.AddShape(c1Shape);
map.AddShape(c2Shape);
map.AddShape(c3Shape);
map.AddShape(c4Shape);
// マップ ビューを、シェイプで使用したのと同じポイントに設定します。
map.SetMapView(points);
// ボタンの状態を切り替えます。
btnDeleteShape.disabled = 0;
btnAddShape.disabled = "disabled";
btnHideShape.disabled = 0;
btnShowShape.disabled = "disabled";
}
function DeleteShape()
{
// シェイプを削除します。
map.DeleteShape(shape);
// ボタンの状態を切り替えます。
btnDeleteShape.disabled = "disabled";
btnAddShape.disabled = 0;
btnHideShape.disabled = "disabled";
btnShowShape.disabled = "disabled";
}
function HideShape()
{
// シェイプをビュー上で非表示にします。
shape.Hide();
// ボタンの状態を切り替えます。
btnDeleteShape.disabled = 0;
btnAddShape.disabled = "disabled";
btnHideShape.disabled = "disabled";
btnShowShape.disabled = 0;
}
function ShowShape()
{
// もう一度シェイプを表示します。
shape.Show();
// ボタンの状態を切り替えます。
btnDeleteShape.disabled = 0;
btnAddShape.disabled = "disabled";
btnHideShape.disabled = 0;
btnShowShape.disabled = "disabled";
}
function ClearMap()
{
map.Clear();
}
</script>
</head>
<body onload="GetMap();">
<div id='myMap' style="position:relative; width:400px; height:400px;"></div>
<input id="btnAddShape" type="button" value="シェイプを追加する"
name="addshape" onclick="AddShape()"><br />
<input id="btnDeleteShape" type="button" value="シェイプを削除する"
name="deleteshape" onclick="DeleteShape()"><br />
<input id="btnHideShape" type="button" value="シェイプを非表示にする"
name="hideshape" onclick="HideShape()"><br />
<input id="btnShowShape" type="button" value="シェイプを表示する"
name="showshape" onclick="ShowShape()"><br />
<input id="btnClear" type="button" value="マップをクリアする"
name="clearmap" onclick="ClearMap()">
</body>
</html>