I am wondering if you have a simple example or some methodology for this. I am looking to draw a polygon using the InteractiveTrackOverlay with TrackMode as Polygon. I want to be able to snap a potential vertex of the polygon to an existing vertex. I tried doing it where I query the ‘snap-to-layer’ and move my mouse pointer (e) there. However, when I add a point, it still takes just where my mouse clicked, not the closest vertex. Is there a way that I can override the mouse click location when adding a vertex to accomplish this?
I read through the code examples, and they all deal with the EditOverlay and making edits to features that already exist. I am not sure if there is a way to tie in snapping in the creation of features, or if there is a work-around I might not be seeing. My code is below for the method I am currently using. But like I said, it only moves the line to the vertex and still captures the x-y of the mouse click, not the vertex. It can look good in the program, but when I load the data into something like ArcMap, I can see the distance between my target vertex and my mouse click.
SubTrackOverlay_MouseMoved(ByValsenderAsObject,ByValeAsMouseMovedTrackInteractiveOverlayEventArgs)
Ife IsNotNothingThenDimxOverlayAsNewLayerOverlayxOverlay = WpfMap_Main.Overlays(“WorkLayers”)DimsnapToLayerAsNewShapeFileFeatureLayersnapToLayer = xOverlay.Layers(0)DimsnapToCollectionAsNewCollection(Of Feature)DimcurrentPointAsNewPointShape(e.MovedVertex.X, e.MovedVertex.Y)
'grab points in the current extent - put into collectionsnapToCollection = snapToLayer.QueryTools.GetFeaturesNearestTo(NewPointShape(e.MovedVertex.X, e.MovedVertex.Y), GeographyUnit.Meter, 1, ReturningColumnsType.NoColumns)
'find distance between mouse pointer and closest featureDimdistanceAsDouble= currentPoint.GetDistanceTo(snapToCollection.Item(0).GetShape(), GeographyUnit.Meter, DistanceUnit.Meter)
'if less than 20 meters, snap to itIfdistance < 20ThenDimsnapToVertexAsNewVertex(snapToCollection.Item(0).GetShape)e.MovedVertex = snapToVertex
EndIfsnapToCollection.Clear()EndIfEndSub