Select to view content in your preferred language

zoom to feature from Featuredat grid after query execution

2830
1
12-09-2011 02:43 AM
ManojrajTeli
Deactivated User
I ma binding the result to graphic layer and from graphics layer i am publishing the attributes into feature data grid but the zoom to selected feature is not working at all

Below is the code
 void queryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs e)
        {
            GraphicsLayer graphicsLayer = Map.Layers["MyGraphicsLayer"] as GraphicsLayer;
            graphicsLayer.ClearGraphics();
            FeatureSet featureset = e.FeatureSet;
            featureset.SpatialReference = Map.SpatialReference;
            if (featureset != null && featureset.Features.Count>0 )
            {
                foreach (Graphic resultfeature in featureset.Features)
                {
                     switch (featureset.GeometryType.ToString())
                     {
                         case "Polygon":
                             resultfeature.Symbol = LayoutRoot.Resources["DefaultQueryFillSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
                             break;
                         case "Polyline":
                             resultfeature.Symbol = LayoutRoot.Resources["DefaultQueryLineSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
                             break;
                         case "Point":
                             resultfeature.Symbol = LayoutRoot.Resources["DefaultQueryMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
                             break;
                     }
                     graphicsLayer.Graphics.Add(resultfeature);
                     System.Windows.Data.Binding bind = new System.Windows.Data.Binding();
                     bind.ElementName = "Map";
                     bind.Path = new PropertyPath("Layers.[MyGraphicsLayer]");
                     MyDataGrid.SetBinding(ESRI.ArcGIS.Client.Toolkit.FeatureDataGrid.GraphicsLayerProperty, bind);
                     MyDataGrid.UpdateLayout();
                }
            }
}




private void MyDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            DataGrid datagrid = sender as DataGrid;
            int selectedindex = datagrid.SelectedIndex;
            if (selectedindex > -1)
            {
                FindResult findresult = (FindResult)MyDataGrid.SelectedItem;
                Graphic graphic = findresult.Feature;
                switch (graphic.Attributes["Shape"].ToString())
                {
                    case "Polygon":
                        graphic.Symbol = LayoutRoot.Resources["DefaultQueryFillSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
                        break;
                    case "Polyline":
                        graphic.Symbol = LayoutRoot.Resources["DefaultQueryLineSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
                        break;
                    case "Point":
                        graphic.Symbol = LayoutRoot.Resources["DefaultQueryMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
                        break;

                }
                GraphicsLayer graphicsLayer = Map.Layers["MyGraphicsLayer"] as GraphicsLayer;
                graphicsLayer.ClearGraphics();
                graphicsLayer.Graphics.Add(graphic);
            }
}



also i am assigning symbology in graphics layer directly. I want to assign the symbology when i am selecting record from feature data grid and zoom to feature.Thank you in advance.I tried example from find and query from esri blog still not working..
0 Kudos
1 Reply
DominiqueBroux
Esri Frequent Contributor
Did you look at this thread ?
There is code to extend the 'Find' sample in order to get zoom working.
0 Kudos