PolygonHotSpot クラス
アセンブリ: System.Web (system.web.dll 内)


このクラスは、ImageMap コントロールに多角形のホット スポット領域を定義します。PolygonHotSpot は、不規則な形状のホットスポット領域を ImageMap コントロールに定義する場合に便利です。たとえば、地図の中に個別の領域を定義するために使用できます。
PolygonHotSpot の領域を定義するには、PolygonHotSpot オブジェクトの各頂点の座標を指定する文字列を Coordinates プロパティに設定します。多角形の頂点とは、多角形の 2 辺が交わる点です。
PolygonHotSpot オブジェクトをクリックすると、URL へのページ移動、サーバーへのポストバックの生成が行われるか、または何も起こりません。この動作は、HotSpotMode プロパティで指定します。URL に移動するには、HotSpotMode プロパティを HotSpotMode.Navigate に設定し、NavigateUrl プロパティを使用して移動先の URL を指定します。サーバーにポストバックするには、HotSpotMode プロパティを HotSpotMode.PostBack に設定し、PostBackValue プロパティを使用して PolygonHotSpot オブジェクトの名前を指定します。この名前は、PolygonHotSpot がクリックされたときに、ImageMapEventArgs イベント データに渡されます。PolygonHotSpot オブジェクトが何も動作を行わないようにするには、HotSpotMode プロパティを HotSpotMode.Inactive に設定します。

3 つの PolygonHotSpot オブジェクトを持つ ImageMap コントロールを作成する方法を次のコード例に示します。各 PolygonHotSpot オブジェクトは、地図上の地理的な領域を表します。ユーザーが PolygonHotSpot オブジェクトをクリックすると、サーバーへのポストバックが行われ、ホット スポットの種類と名前がラベルに表示されます。
<%@ Page Language="VB" %> <script runat="server"> 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 Class Example</title> </head> <body> <form id="Form1" runat="server"> <h3>PolygonHotSpot 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:PolygonHotSpot coordinates="128,185,335,157,400,224,400,400,228,400" postbackvalue="Southern" alternatetext="Southern 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 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 Class Example</title> </head> <body> <form id="Form1" runat="server"> <h3>PolygonHotSpot 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:PolygonHotSpot coordinates="128,185,335,157,400,224,400,400,228,400" postbackvalue="Southern" alternatetext="Southern Region"> </asp:PolygonHotSpot> </asp:imagemap> <br /><br /> <asp:label id="Message1" runat="Server"> </asp:label> </form> </body> </html>


System.Web.UI.WebControls.HotSpot
System.Web.UI.WebControls.PolygonHotSpot


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 メンバ
System.Web.UI.WebControls 名前空間
ImageMap クラス
Coordinates
その他の技術情報
ImageMap Web サーバー コントロール
- PolygonHotSpot クラスのページへのリンク