I'm currently struggling with the query returning the attributes okay, but graphics are always null. I tried the featurelayer code with no success.Does the service have to have Feature Access selected? Currently the service has just Mapping.
var layer = new FeatureLayer() { Url = string.Format("{0}/{1}", dynamicLayer.Url, i), }; MyMap.Layers.Add(layer); featureDataGrid1.GraphicsLayer = layer;
for (int i = 0; i < theSubLayers.Count(); i++) { theLayInfo = (LayerInfo)theSubLayers.GetValue(i); if (theLayInfo.Name == theActiveLayerName) { //Do a query to return all the records for the featuredatagrid QueryTask theQueryTask = new QueryTask(); theQueryTask.ExecuteCompleted += Query_ExecuteCompleted; Query theQuery = new Query(); theQuery.ReturnGeometry = true; theQuery.Where = "1=1"; theQuery.OutSpatialReference = MyMap.SpatialReference; theQuery.OutFields.Add("*"); theQueryTask.Url = dynamicLayer.Url + "/" + i.ToString(); theQueryTask.ExecuteAsync(theQuery, "initial"); break; } }
FeatureLayer theFeatureLayer = new FeatureLayer(); FeatureSet theFeatSet = args.FeatureSet; if (theFeatSet != null && theFeatSet.Features.Count > 0) { GraphicsLayer theGraphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; theGraphicsLayer.Graphics.Clear(); foreach (Graphic theGFeature in theFeatSet.Features) { theGraphicsLayer.Graphics.Insert(0, theGFeature); } featureDataGrid1.GraphicsLayer = theGraphicsLayer; //Set renderer to the graphics layer IRenderer theRenderer; theRenderer = grid1.Resources["SelectRenderer"] as ESRI.ArcGIS.Client.IRenderer; theGraphicsLayer.Renderer = theRenderer; }
No this is not supported.FeatureDataGrid.GraphicsLayer must be of type GraphicsLayer. FeatureLayer for example inherits from GraphicsLayer. You can either perform a query on this sub layer URL and put the results in a GraphicsLayer or create a FeatureLayer with this sub layer URL, then use this layer to set FeatureDataGrid.GraphicsLayer property.
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.