I have polygon shapes on my map that I want to have the user size (rectangles but not necessarily flat on the X/Y axis). Is there any way to set the edit overlay so that when I drag a control point on the corner the adjacent control points move so that the rectangular shape remains rather than just having the single control point move?
PolygonShape polygonShape = sourceFeature.GetShape() as PolygonShape;
int fixedPointIndex = GetFixedPointIndex(polygonShape, sourceControlPoint);
PointShape fixedPointShape = new PointShape(polygonShape.OuterRing.Vertices[fixedPointIndex]);
if (resizeMode == ResizeMode.OnePointFixed) { RectangleShape newRectangleShape = new LineShape(new Vertex[] { new Vertex(fixedPointShape), new Vertex(targetControlPoint) }).GetBoundingBox(); editedFeature = new Feature(newRectangleShape.GetWellKnownBinary(), sourceFeature.Id, sourceFeature.ColumnValues);
What a great example, thanks from me, Yale. I have a couple of questions on it, please.
1) In my application, the user has already selected the feature she wants to edit when I copy it into the EditInteractiveOverlay, so how can I put the new feature into an edit mode right away, rather than making the user select it again?
2) Is there already a mechanism for the user to signal she is done editing, or must I provide one (and if it’s the latter, do you have an example I can re-use)?
1. there are two ways to to edit a feature. One is using mouse to select it as you already know; the other one is to add this feature to EditInteractiveOverlay directly. There is an InMemoryFeatureLayer called EditShapeLayer in EditInteractiveOverlay, you can add the features to the InternalFeatures property of it.
2. It will raise an event when each operation (such rotate, drag, add vertex etc) start or end. I think you can use the end event as the signal of done editing.
My first question was more aimed at the question of how to put a feature into editing mode automatically, so the control points for editing are available to the user without making her select the feature a 2nd time. I'm adding my current code below, please let me know where I need to add or change something to show the feature ready to be edited:
RectangleShape newRectangleShape = currentlySelectedFeature.GetBoundingBox() as RectangleShape;
I think this block of code is enough, the control points will show on the map after executing these codes and you can edit the feature directly by the control points without nothing more operation. There is a simple sample in the attachment to show you how it works base on the CustomerEditInteractiveOverlay in this post. Any more questions please let us know. Thanks, sun
The map is still not entering edit mode automatically - the user still has to select the feature again to edit it. It is also not refreshing automatically when the feature is removed, in spite of many calls to wpfMap.refresh()