Select to view content in your preferred language

how to dinamically set the FeatureDataGrid to a feature layer

654
4
01-28-2013 11:31 AM
Labels (1)
FrancoisGilbert
Deactivated User
Hello,

I am working on a map to display the feature dataset information using the featuredatagrid. So far, I have been able to query a layer, store the query result in a graphic layer. From that graphic layer, I have assigned the following property and I am able to see the the table details of the selected objects in the layer. I use the following code to do the work.

MyDataGrid.GraphicsLayer = graphicsLayer

What I would like to offer also would be to allow the user to have acces to the whole feature layer in terms of table description . I would like to dynamically chose from my comboxbox the layer and display all the features that belong to the feature layer.

Private Sub MyDrawSurface_DrawComplete(sender As Object, args As ESRI.ArcGIS.Client.DrawEventArgs)
            Dim selectionGraphicslayer As GraphicsLayer = TryCast(MyMap.Layers("MySelectionGraphicsLayer"), GraphicsLayer)

            selectionGraphicslayer.ClearGraphics()

            Dim queryTask As New QueryTask()
            queryTask.Url = _MapService.UrlMapService & "/" & _sSelectedLayerID

            AddHandler queryTask.ExecuteCompleted, AddressOf QueryTask_ExecuteCompleted
            AddHandler queryTask.Failed, AddressOf QueryTask_Failed
            Dim resultFeaturesBinding As New Binding("LastResult.Features")
            resultFeaturesBinding.Source = queryTask
            Dim query As Query = New ESRI.ArcGIS.Client.Tasks.Query()
            'query.OutFields.AddRange(New String() {"STATE_NAME"})
            query.OutFields.AddRange(New String() {"*"})   ' * prend toutes les colonnes
            query.Geometry = args.Geometry
            query.ReturnGeometry = True
            queryTask.ExecuteAsync(query)
            _oMyDrawObject.IsEnabled = False

        End Sub

Private Sub QueryTask_ExecuteCompleted(sender As Object, args As ESRI.ArcGIS.Client.Tasks.QueryEventArgs)
            Dim featureSet As FeatureSet = args.FeatureSet
            Dim sOJBID As String = ""

            If featureSet Is Nothing OrElse featureSet.Features.Count < 1 Then
                MessageBox.Show("La sélection n'a retourné aucuns objets")
                Return
            End If
            Dim graphicsLayer As GraphicsLayer = TryCast(MyMap.Layers("MySelectionGraphicsLayer"), GraphicsLayer)

            MyMapTip.GraphicsLayer = graphicsLayer  'to remove
            MyDataGrid.GraphicsLayer = graphicsLayer  'to remove

            If featureSet IsNot Nothing AndAlso featureSet.Features.Count > 0 Then
                For Each feature As Graphic In featureSet.Features
                    Select Case featureSet.GeometryType
                        Case GeometryType.Polygon
                            feature.Symbol = TryCast(LayoutRoot.Resources("DefaultFillSymbol"), FillSymbol)
                            Exit Select
                        Case GeometryType.Polyline
                            feature.Symbol = TryCast(LayoutRoot.Resources("DefaultLineSymbol"), LineSymbol)
                            Exit Select
                        Case GeometryType.Point
                            feature.Symbol = TryCast(LayoutRoot.Resources("DefaultMarkerSymbol"), MarkerSymbol)
                            Exit Select
                    End Select
                    'feature.Symbol = TryCast(LayoutRoot.Resources("ResultsFillSymbol"), FillSymbol)
                    graphicsLayer.Graphics.Insert(0, feature)

                    sOJBID = sOJBID & "OBJECTID= " & feature.Attributes.Values(0).ToString & ", " & feature.Attributes.Values(1).ToString & vbLf
                Next
                'MessageBox.Show(sOJBID)
            End If

            _oMyDrawObject.IsEnabled = False
        End Sub
0 Kudos
4 Replies
MichaelBranscomb
Esri Frequent Contributor
Hi,

You should only need to pass the FeatureLayer to the GraphicsLayer property of the FeatureDataGrid (FeatureLayer derives from GraphicsLayer) e.g.:

MyDataGrid.GraphicsLayer = myFeatureLayer


Cheers

Mike
0 Kudos
FrancoisGilbert
Deactivated User
Hello Mike,

I indeed want to make the assignement you mentionned.            "MyDataGrid.GraphicsLayer = myFeatureLayer"

Juste before that assignement, I have access to the dynamic MapServiceLayer with the following line of code that works

"Dim dynamicServiceLayer As ArcGISLocalDynamicMapServiceLayer = TryCast(sender, ArcGISLocalDynamicMapServiceLayer)"

Can you tell me how I could assing "myFeatureLayer" to one of the layer that is contain in the dynamicServiceLayer, the following line does not work.

"myFeatureLayer= TryCast(dynamicServiceLayer.Layers(2), FeatureLayer)"
0 Kudos
FrancoisGilbert
Deactivated User
Hello Mike,

I have also tried to do the following that does not work. From the dynamic map service, I want to reference a feature layer that represents a sub layer and assign it to the featuredatagrid so that it shows the whole feature dataset.


Dim myFeatureLayer As New ESRI.ArcGIS.Client.FeatureLayer
myFeatureLayer.Url = _MapService.UrlMapService & "/" & _sSelectedLayerID
myFeatureLayer.IgnoreServiceScaleRange = True

Regards
François
0 Kudos
FrancoisGilbert
Deactivated User
Hello,

I have found the answer to my question. I have defined a query and have been able to set the featuredtagrid to one of my sublayer. Unfortunately, I need to create a query and add a graphic layer to the map that I made invisible.

I thought I would be able to simply reference an existing layer but this is  not the way ArcGis Runtime works I guess.


François
0 Kudos