ArcIMS BlueViewer
ArcIMS_BlueViewer_VBNet\legend.aspx.vb
' Copyright 2010 ESRI
' 
' All rights reserved under the copyright laws of the United States
' and applicable international laws, treaties, and conventions.
' 
' You may freely redistribute and use this sample code, with or
' without modification, provided you include the original copyright
' notice and use restrictions.
' 
' See the use restrictions.
' 

 

Namespace BlueViewer

Partial Class Legend
    Inherits System.Web.UI.Page
    Protected WithEvents lblTitle As System.Web.UI.WebControls.Label

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
    End Sub

    Private Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.PreRender

        Dim legendURL As String

        If Session("VALID_USER") = True Then

            Dim sServer As String = ConfigurationSettings.AppSettings("DEFAULT_MAPSERVER")
            Dim iPort As Integer = CInt(ConfigurationSettings.AppSettings("DEFAULT_MAPPORT"))
            Dim sService As String = ConfigurationSettings.AppSettings("DEFAULT_MAPSERVICE")
            Dim iWidth As Integer = CInt(Request.QueryString("WIDTH"))
            Dim iHeight As Integer = CInt(Request.QueryString("HEIGHT"))

                Dim conArcIMS As New ESRI.ArcGIS.ADF.Connection.IMS.TCPConnection(sServer, iPort)
                Dim axlRequest As New ESRI.ArcGIS.ADF.Connection.IMS.XML.AxlRequests
            Dim axlResponse As New System.Xml.XmlDocument
            conArcIMS.ServiceName = sService

            Dim sAXLText As String
            sAXLText = "<?xml version=""1.0"" encoding=""UTF-8""?><ARCXML version=""1.1"">"
            sAXLText = sAXLText & "<REQUEST><GET_IMAGE><PROPERTIES>"
            sAXLText = sAXLText & "<IMAGESIZE width=""" & iWidth & """ height=""" & iHeight & """/>"
            sAXLText = sAXLText & "<ENVELOPE minx=""" & Request.QueryString("XMIN") & """ miny=""" & Request.QueryString("YMIN") & """ maxx=""" & Request.QueryString("XMAX") & """ maxy=""" & Request.QueryString("YMAX") & """ />"
            sAXLText = sAXLText & "<LEGEND display=""true"" autoextend=""true"" font=""Verdana"" />"
            sAXLText = sAXLText & "</PROPERTIES></GET_IMAGE></REQUEST></ARCXML>"

            axlResponse.LoadXml(conArcIMS.Send(sAXLText))
            If axlResponse.GetElementsByTagName("LEGEND").Count = 1 Then
                Dim nodeOutput As System.Xml.XmlNodeList = axlResponse.GetElementsByTagName("LEGEND")
                legendURL = nodeOutput(0).Attributes("url").Value
            End If

            imgLegend.ImageUrl = legendURL
        Else
            Response.Write("Error: Page Inaccessible.")
        End If
    End Sub
End Class

End Namespace