Dim theMapItem As MapItem
Dim m_disp As MapDisplay = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay
'Define the connection properties
Dim connProps As ServiceConnectionProperties = New ServiceConnectionProperties(ServiceType.Ims, New Uri("http://nowcoast.noaa.gov"), "nowcoast")
'Create a new ServiceLayer
Dim svcLayer As ServiceLayer = New ServiceLayer(connProps)
'Name Layer
svcLayer.Name = "Hurricane Track"
'Connect to Service
Dim connected As Boolean = svcLayer.Connect()
'Add the layer to the map.
'Check to see whether the connection was successful
If (connected) Then
'Add the layer to the map.
theMapItem = svcLayer.FindByName("Tropical Cyclone Track Lines")
If Not (theMapItem Is Nothing) Then
theMapItem.RemoveFromParent()
theMapItem = Nothing
End If
m_disp.Map.ChildItems.Add(svcLayer)
Else
'Investigate connection issue.
MsgBox("Server Connection Failed!")
Dim status As ConnectionStatus = svcLayer.ConnectionStatus
If status.HasError Then
System.Diagnostics.Debug.Print(status.ErrorString)
End If
End If
Dim m_disp As MapDisplay = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay
'Define the connection properties
Dim connProps As ServiceConnectionProperties = New ServiceConnectionProperties(ServiceType.Ims, New Uri("http://nowcoast.noaa.gov"), "nowcoast")
'Create a new ServiceLayer
Dim svcLayer As ServiceLayer = New ServiceLayer(connProps)
'Name Layer
svcLayer.Name = "Hurricane Track"
'Connect to Service
Dim connected As Boolean = svcLayer.Connect()
'Array list of layers to connect to
Dim LayerList As New ArrayList()
LayerList.Add("Tornado Warnings")
LayerList.Add("Flood Warnings")
LayerList.Add("Flash Flood Warnings")
LayerList.Add("Severe Thunderstorm Warnings")
LayerList.Add("Extreme Wind Warnings")
'Check to see whether the connection was successful and add layers from Array List
If (connected) Then
For Each NOAALayer As String In LayerList
For Each lyr As ServiceChildLayer In svcLayer.ChildItems
If lyr.Name = NOAALayer Then
lyr.Visible = True
m_disp.Map.ChildItems.Add(lyr)
Else
lyr.Visible = False
End If
Next
Next
Else
'Investigate connection issue.
Dim status As ConnectionStatus = svcLayer.ConnectionStatus
MsgBox("Server Connection Failed!" & status.ErrorString)
If status.HasError Then
System.Diagnostics.Debug.Print(status.ErrorString)
End If
End If
End Sub