Parameters
- layer
- The layer of the feature to move.
- oid
- The oid of the feature to move.
- dx
- Units along the x-axis to move the geometry.
- dy
- Units along the y-axis to move the geometry.
// Moves the shapes (geometries) of all selected features of a given feature layer of the active map view by a fixed offset. await QueuedTask.Run<bool>(() => { double xOffset = 100; // specify your units along the x-axis to move the geometry double yOffset = 100; // specify your units along the y-axis to move the geometry // If there are no selected features, return if (featureLayer.GetSelection().GetObjectIDs().Count == 0) return false; // set up a dictionary to store the layer and the object IDs of the selected features var selectionDictionary = new Dictionary<MapMember, List<long>> { { featureLayer, featureLayer.GetSelection().GetObjectIDs().ToList() } }; var moveEditOperation = new EditOperation() { Name = "Move features" }; moveEditOperation.Move(SelectionSet.FromDictionary(selectionDictionary), xOffset, yOffset); //specify your units along axis to move the geometry if (!moveEditOperation.IsEmpty) { var result = moveEditOperation.Execute(); return result; // return the operation result: true if successful, false if not } return false; // return false to indicate that the operation was not empty });
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)