I'm creating a MapTool and I need it to be able to snap to a line. Within Pro, I have edge snapping 'enabled' and snapping turned on. I also have Snapping turn on through the code in the MapTool, but either way I cannot get the little 'cross hair' cursor to snap to anything.
Where am I going wrong with this??
protected override Task OnToolActivateAsync(bool active)
{
Snapping.IsEnabled = true;
Snapping.SetSnapMode(SnapMode.Edge, true);
Snapping.SetSnapMode(SnapMode.End, true);
return base.OnToolActivateAsync(active);
}
Solved! Go to Solution.
HI Brian,
The UseSnapping property on maptool determines if the tool will use the snap environment.
You would normally set this to True in the tools constructor. Its False by default.
public SketchSelect()
{
IsSketchTool = true;
SketchType = SketchGeometryType.Line;
SketchOutputMode = SketchOutputMode.Map;
UseSnapping = true;
HI Brian,
The UseSnapping property on maptool determines if the tool will use the snap environment.
You would normally set this to True in the tools constructor. Its False by default.
public SketchSelect()
{
IsSketchTool = true;
SketchType = SketchGeometryType.Line;
SketchOutputMode = SketchOutputMode.Map;
UseSnapping = true;
Great. Thanks Sean Jones.
Another related question: Is it possible to snap to a graphic that is drawn on the screen? In my case, I have a tool that creates graphics along of a sewer segment to show where residential sewer connections are coming into the pipe (red graphics). Ideally I would be able to snap to these red graphics and not just the line.
Hey Brian,
Graphics created with the AddOverlay methods cant be snapped too, they arent in the snapping cache. We do want to add this in a future release.
You can look into graphics layers, which are new at 2.6, that lets users draw persisted snappable graphics and its API.
Great. Yes, I haven't updated my code since 2.6 came out, so I will look into graphics layers and see if that fixes my problem.
Thanks!