//removegraphic = featureLayer.Graphics.FirstOrDefault(g => (int)g.Attributes[layer.LayerInfo.ObjectIdField] == idToDelete);if (graphic != null) featureLayer.Graphics.Remove(graphic);
FeatureLayer l = new FeatureLayer() { Url = "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Fire/Sheep/FeatureServer/0" , ObjectIDs = new int[]{11688} }; l.OutFields.Add("*"); l.Initialized += (s, e) => { if (l.InitializationFailure == null) l.Update(); }; l.UpdateCompleted += (s, e) => { var graphic = l.Graphics.FirstOrDefault(g => (int)g.Attributes[l.LayerInfo.ObjectIdField] == 11688); if (graphic != null) graphic.Attributes["description"] = string.Format("Updated this field on {0}", DateTime.UtcNow); }; l.EndSaveEdits += (s, e) => { if(e.Results!= null || e.Results.UpdateResults!=null) { foreach (var r in e.Results.UpdateResults) MessageBox.Show(string.Format("Updated id ({0})", r.ObjectID)); } }; l.Initialize();
//add var graphic = new Graphic() {Geometry = new MapPoint(x,y)} graphic.Attributes["fieldName"] = fieldValue; featureLayer.Graphics.Add(graphic); //remove graphic = featureLayer.Graphics.FirstOrDefault(g => (int)g.Attributes[layer.LayerInfo.ObjectIdField] == idToDelete); if (graphic != null) featureLayer.Graphics.Remove(graphic); //edit graphic = featureLayer.Graphics.FirstOrDefault(g => (int)g.Attributes[layer.LayerInfo.ObjectIdField] == idToEdit); graphic.Geometry = new MapPoint(x,y); graphic.Attributes["fieldName"] = newFieldValue;
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.