PolygonHotSpot.Coordinates プロパティ
アセンブリ: System.Web (system.web.dll 内)

Dim instance As PolygonHotSpot Dim value As String value = instance.Coordinates instance.Coordinates = value
/** @property */ public String get_Coordinates () /** @property */ public void set_Coordinates (String value)
PolygonHotSpot オブジェクトの各頂点の座標を表す文字列。

Coordinates プロパティを使用して、PolygonHotSpot オブジェクトの各頂点の座標を指定します。多角形の頂点とは、多角形の 2 辺が交わる点です。指定する文字列は、それぞれの座標をコンマで区切った形式にする必要があります。指定する各頂点には、x 座標と y 座標の両方を含める必要があります。たとえば、"128,185,335,157,510,224,510,383,228,383" という文字列は、5 つの頂点を持つ多角形ホット スポットを定義します。最初の頂点の x 座標は 128 で、y 座標は 185 です。

プログラムによって PolygonHotSpot オブジェクトを作成し、ImageMap コントロールに追加する方法を次のコード例に示します。Coordinates プロパティを使用して、PolygonHotSpot オブジェクトの各頂点の座標を指定します。ImageMap コントロールには、宣言によって追加された別の 2 つの PolygonHotSpot オブジェクトが含まれます。各 PolygonHotSpot オブジェクトは、地図上の地理的な領域を表します。ユーザーが PolygonHotSpot オブジェクトをクリックすると、サーバーへのポストバックが行われ、ホット スポットの種類と名前がラベルに表示されます。
<%@ Page Language="VB" %> <script runat="server"> Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) ' Programmatically create a PolygonHotSpot. Dim Polygon1 As New PolygonHotSpot Polygon1.Coordinates = "128,185,335,157,400,224,400,400,228 ,400" Polygon1.PostBackValue = "Southern" Polygon1.AlternateText = "Southern Region" ' Add it to the end of the ImageMap control's ' HotSpotCollection. Regions.HotSpots.Add(Polygon1) End Sub Sub RegionMap_Clicked(ByVal sender As Object, ByVal e As ImageMapEventArgs) Dim hotSpotType As String ' When a user clicks a hot spot, display ' the hot spot's type and name. Select Case (e.PostBackValue) Case ("Western") hotSpotType = Regions.HotSpots(0).ToString() Message1.Text = "You selected " & hotSpotType & " " & e.PostBackValue Case ("Northern") hotSpotType = Regions.HotSpots(1).ToString() Message1.Text = "You selected " & hotSpotType & " " & e.PostBackValue Case ("Southern") hotSpotType = Regions.HotSpots(2).ToString() Message1.Text = "You selected " & hotSpotType & " " & e.PostBackValue Case Else Message1.Text = "You did not click a valid hot spot region." End Select End Sub </script> <html> <head id="Head1" runat="server"> <title>PolygonHotSpot Constructor Example</title> </head> <body> <form id="Form1" runat="server"> <h3>PolygonHotSpot Constructor Example</h3> <!-- Change or remove the width and height attributes as appropriate for your image. --> <asp:imagemap id="Regions" imageurl="Images/RegionMap.jpg" alternatetext="Sales Regions" hotspotmode="PostBack" width="400" height="400" onclick="RegionMap_Clicked" runat="Server"> <asp:PolygonHotSpot coordinates="0,0,176,0,125,182,227,400,0,400" postbackvalue="Western" alternatetext="Western Region"> </asp:PolygonHotSpot> <asp:PolygonHotSpot coordinates="177,0,400,0,400,223,335,154,127,180" postbackvalue="Northern" alternatetext="Northern Region"> </asp:PolygonHotSpot> </asp:imagemap> <br /><br /> <asp:label id="Message1" runat="Server"> </asp:label> </form> </body> </html>
<%@ Page Language="C#" %> <script runat="server"> void Page_Load(object sender, EventArgs e) { // Programmatically create a PolygonHotSpot. PolygonHotSpot Polygon1 = new PolygonHotSpot(); Polygon1.Coordinates = "128,185,335,157,400,224,400,400,228,400"; Polygon1.PostBackValue = "Southern"; Polygon1.AlternateText = "Southern Region"; // Add it to the end of the ImageMap control's // HotSpotCollection. Regions.HotSpots.Add(Polygon1); } void RegionMap_Clicked (object sender, ImageMapEventArgs e) { string hotSpotType; // When a user clicks a hot spot, display // the hot spot's type and name. switch (e.PostBackValue) { case "Western": hotSpotType = Regions.HotSpots[0].ToString(); Message1.Text = "You selected " + hotSpotType + " " + e.PostBackValue; break; case "Northern": hotSpotType = Regions.HotSpots[1].ToString(); Message1.Text = "You selected " + hotSpotType + " " + e.PostBackValue; break; case "Southern": hotSpotType = Regions.HotSpots[2].ToString(); Message1.Text = "You selected " + hotSpotType + " " + e.PostBackValue; break; default: Message1.Text = "You did not click a valid hot spot region."; break; } } </script> <html> <head id="Head1" runat="server"> <title>PolygonHotSpot Constructor Example</title> </head> <body> <form id="Form1" runat="server"> <h3>PolygonHotSpot Constructor Example</h3> <!-- Change or remove the width and height attributes as appropriate for your image. --> <asp:imagemap id="Regions" imageurl="Images/RegionMap.jpg" alternatetext="Sales Regions" hotspotmode="PostBack" width="400" height="400" onclick="RegionMap_Clicked" runat="Server"> <asp:PolygonHotSpot coordinates="0,0,176,0,125,182,227,400,0,400" postbackvalue="Western" alternatetext="Western Region"> </asp:PolygonHotSpot> <asp:PolygonHotSpot coordinates="177,0,400,0,400,223,335,154,127,180" postbackvalue="Northern" alternatetext="Northern Region"> </asp:PolygonHotSpot> </asp:imagemap> <br /><br /> <asp:label id="Message1" runat="Server"> </asp:label> </form> </body> </html>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- PolygonHotSpot.Coordinates プロパティのページへのリンク