Select to view content in your preferred language

Snapping in the Editing functionality

932
5
02-17-2011 11:42 PM
JollyJacob
Emerging Contributor
Hi,

While editing features in the Web map viewer, is it possible to snap to edges, vertices and nodes of the edited layer? Also, extrude and reduce the polygon by a specified value? This is an absolute must-have for the client, so any help will be much appreciated.

Thanks
Jolly
0 Kudos
5 Replies
JenniferNery
Esri Regular Contributor
Snapping is demonstrated in any of our Editing samples that use EditVertices command.

You can look at this sample for Default behavior:
http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#EditToolsExplicitSave

and this sample for Customized behavior:
http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#EditToolsAutoSave

In the second sample the following properties are set on the map:
esri:Editor.SnapDistance="20" esri:Editor.SnapKey="S"

The default values are SnapDistance of 15 pixels and SnapKey is CTRL.

While EditVertices command is active, you drag a vertex while pressing on SnapKey and it will try to snap to vertices of other graphics that is within the given SnapDistance proximity.

As for extrusion, Do you mean extrude polygon in 3D as described here:
http://webhelp.esri.com/arcgisdesktop/9.3/tutorials/3D_analyst/3D_9_5.htm

We currently do not support 3D.
0 Kudos
JollyJacob
Emerging Contributor
Thanks for the Jennifer, the snapping sample was of great help.

Sorry, I used the wrong word, not 'extrude' but 'extend'. We would like to extend a polyline / polygon feature by a user-defined 'x' value and likewise trim it by say 'y' value.
0 Kudos
JenniferNery
Esri Regular Contributor
Oh you mean scale the geometry? Scale and Rotate is new to v2.2. You can join our beta community to test it out and see if this is something you can use for your application.

However, the Editor.EditVertices with ScaleEnabled=True, does not include a programmatic way of doing something like "ScaleX by some x amount and ScaleY by some y amount" as you suggested.
0 Kudos
JollyJacob
Emerging Contributor
Thanks for your reply Jennifer. In the Municipality for which we are doing this project, they sometimes need to extend / contract plot geometry and they want to be able to do so using a user-defined value rather than an arbitary click-and-drag of the mouse extension. If we can't do that using the SL API that pretty much rules out SL and we might have to try this in Javascript instead.
0 Kudos
JenniferNery
Esri Regular Contributor
You can also update graphic Geometry in code-behind without using the Editor.
For example:
private void GraphicsLayer_MouseLeftButtonDown(object sender, GraphicMouseButtonEventArgs e)
{
 Polyline polyline = e.Graphic.Geometry as Polyline;
 Envelope current = polyline.Extent;
 Envelope expand = current.Expand(10);
 Polyline scaled = new Polyline();
 double sx = current.Width > 0 ? expand.Width / current.Width : 1d;
 double sy = current.Height > 0 ? expand.Height / current.Height : 1d;
 foreach (var path in polyline.Paths)
 {
  PointCollection pts = new PointCollection();
  foreach (var p in path)
   pts.Add(new MapPoint((p.X - current.XMin) * sx + expand.XMin, (p.Y - current.YMin) * sy + expand.YMin));
  scaled.Paths.Add(pts);
 }
 e.Graphic.Geometry = scaled;
}
0 Kudos