Select to view content in your preferred language

Dynamic line when drawing from one vertex to another

1864
6
08-10-2018 06:05 AM
BradyHoukom1
Deactivated User

We would like the ability to see the line when connecting two vertices of a polygon (before creating the new vertex). Our old application using 10.2.7 seems to have this functionality but I can't find it using 100.1 does not. I have searched everywhere without any luck. 

Is there a way to activate this functionality in the MapView or in the SketchEditor?

0 Kudos
6 Replies
JenniferNery
Esri Regular Contributor

In v100.3, SketchEditor was enhanced to show draw feedback, which allows you to see how the geometry will look like before the vertex is committed/inserted as you interactively drag it. Is this what you're looking for?

The symbols to update if you don't like this default symbology is FeedbackFill/Line/VertexSymbol in SketchEditor.Style.

0 Kudos
BradyHoukom1
Deactivated User

Unfortunately, not exactly what I was looking for. Let me clarify. I am looking for something similar to this but I mean while drawing the polygon, not editing it. So let's say that I selected the first vertex, vertex 0, I would like to see a line while I am looking where to place the second vertex, vertex 1. Does that make sense?

0 Kudos
JenniferNery
Esri Regular Contributor

I see. You can programmatically call insert or move vertex. Moving the selected vertex during MouseMove, ManipulationDelta, TouchMove, or any event you see fit, should show the connecting line between last committed vertex to where you're moving cursor/touch point to. Something like this, but you have to find the right condition that works for you to differentiate between insert/move.

int vertexCount = 0;

MyMapView.MouseMove += (s, e) =>
      {
          if (!MyMapView.SketchEditor.IsEnabled || MyMapView.SketchEditor.Geometry == null)
              return;
          var location = MyMapView.ScreenToLocation(e.GetPosition(MyMapView));
          if ((MyMapView.SketchEditor.Geometry as Polygon)?.Parts?.FirstOrDefault()?.PointCount <= vertexCount)
              MyMapView.SketchEditor.InsertVertexAfterSelectedVertex(location);
          else
              MyMapView.SketchEditor.MoveSelectedVertex(location);
      };

MyMapView.GeoViewTapped += (s, e) =>
  {
      vertexCount++;
  };
0 Kudos
BradyHoukom1
Deactivated User

Awesome, I was hoping it would be a property but this is simple enough. Thanks!

0 Kudos
BradyHoukom1
Deactivated User

I guess I replied to myself instead of you. I posted a response below that I am now getting a null reference exception.

0 Kudos
BradyHoukom1
Deactivated User

I am now getting this issue Completing the SketchEditor with a double click sometimes causes the application to crash 

I am using the solution above along with attaching to the GeoViewDoubleTapped event to handle completing the draw action. 

I found that the GeoViewTapped event fires before GeoViewDoubleTapped (obviously). The issue that I am seeing is that InsertVertexAfterSelectedVertex is executed fine, then when the GeoViewDoubleTapped is fired it completes the sketch. Something with the runtime is taking so long to complete the InsertVertexAfterSelectedVertex method call that the sketch actually completes before the vertex is added. Which causes the error that is noted in the link above

Is that if adding a vertex is asynchronous? If it is, then we need the ability to await that method.

0 Kudos