I have implemented the identify sample as shown in the ESRI samples at http://resources.esri.com/help/9.3/arcgisserver/apis/silverlight/samples/start.htm#IdentifyIt seems to work OK BUT . . .My map consists of 2 roadway layers plus any one of 3 layers showing the area's school districts. The 3 school layers are turned on/off by making selections with a checkbox to display elementary, middle, or high schools. My problem is that irregardless of which school layer is displayed, the identify always reveals only the elementary and roadway layer data. How can I cause the identify results to contain the visible school layer data? Code below.Thanks
#Region "Identify"
Private Sub QueryPoint_MouseClick(ByVal sender As Object, ByVal e As ESRI.ArcGIS.Client.Map.MouseEventArgs)
Dim clickPoint As ESRI.ArcGIS.Client.Geometry.MapPoint = e.MapPoint
Dim identifyParams As ESRI.ArcGIS.Client.Tasks.IdentifyParameters = New IdentifyParameters() With {.Geometry = clickPoint, .MapExtent = MyMap.Extent, .Width = CInt(Fix(MyMap.ActualWidth)), .Height = CInt(Fix(MyMap.ActualHeight)), .LayerOption = LayerOption.visible}
Dim identifyTask As New IdentifyTask("http://maps.pagnet.org/arcgis/rest/services/SchoolSearch2/MapServer")
AddHandler identifyTask.ExecuteCompleted, AddressOf IdentifyTask_ExecuteCompleted
AddHandler identifyTask.Failed, AddressOf IdentifyTask_Failed
identifyTask.ExecuteAsync(identifyParams)
Dim graphicsLayer As GraphicsLayer = TryCast(MyMap.Layers("MyGraphicsLayer"), GraphicsLayer)
graphicsLayer.ClearGraphics()
Dim graphic As New ESRI.ArcGIS.Client.Graphic() With {.Geometry = clickPoint, .Symbol = DefaultPictureSymbol}
graphicsLayer.Graphics.Add(graphic)
End Sub
Public Sub ShowFeatures(ByVal results As List(Of IdentifyResult))
_dataItems = New List(Of DataItem)()
If results IsNot Nothing AndAlso results.Count > 0 Then
IdentifyComboBox.Items.Clear()
For Each result As IdentifyResult In results
Dim feature As Graphic = result.Feature
Dim title As String = result.Value.ToString() & " (" & result.LayerName & ")"
_dataItems.Add(New DataItem() With {.Title = title, .Data = feature.Attributes})
IdentifyComboBox.Items.Add(title)
Next result
' Workaround for bug with ComboBox
IdentifyComboBox.UpdateLayout()
IdentifyComboBox.SelectedIndex = 0
End If
End Sub
Private Sub cb_SelectionChanged(ByVal sender As Object, ByVal e As SelectionChangedEventArgs)
Dim index As Integer = IdentifyComboBox.SelectedIndex
If index > -1 Then
IdentifyDetailsDataGrid.ItemsSource = _dataItems(index).Data
End If
End Sub
Private Sub IdentifyTask_ExecuteCompleted(ByVal sender As Object, ByVal args As IdentifyEventArgs)
IdentifyDetailsDataGrid.ItemsSource = Nothing
IdentifyResultsPanel.Visibility = Windows.Visibility.Visible
If args.IdentifyResults IsNot Nothing AndAlso args.IdentifyResults.Count > 0 Then
If DataGridScrollViewer.Visibility = Visibility.Collapsed Then
DataGridScrollViewer.Visibility = Visibility.Visible
IdentifyGrid.Height = Double.NaN
IdentifyGrid.UpdateLayout()
End If
ShowFeatures(args.IdentifyResults)
Else
IdentifyComboBox.Items.Clear()
IdentifyComboBox.UpdateLayout()
If DataGridScrollViewer.Visibility = Visibility.Visible Then
DataGridScrollViewer.Visibility = Visibility.Collapsed
IdentifyGrid.Height = Double.NaN
IdentifyGrid.UpdateLayout()
End If
End If
End Sub
Public Class DataItem
Private privateTitle As String
Public Property Title() As String
Get
Return privateTitle
End Get
Set(ByVal value As String)
privateTitle = value
End Set
End Property
Private privateData As IDictionary(Of String, Object)
Public Property Data() As IDictionary(Of String, Object)
Get
Return privateData
End Get
Set(ByVal value As IDictionary(Of String, Object))
privateData = value
End Set
End Property
End Class
Private Sub IdentifyTask_Failed(ByVal sender As Object, ByVal e As TaskFailedEventArgs)
MessageBox.Show("Identify failed. Error: " & e.Error.Message)
End Sub
#End Region