Hi Dave,
One way of having a sketch tool allow multiple clicks without using the Line sketch is to use the Multipoint geometry type. You can then override the OnSketchModifiedAsync callback to force the sketch to finish after your required number of clicks (in this case 2).
Here's a small snippet that sounds like what you're looking for.
internal class LeaderLineTool : MapTool
{
public LeaderLineTool()
{
IsSketchTool = true;
SketchType = SketchGeometryType.Multipoint;
SketchOutputMode = SketchOutputMode.Map;
}
protected override Task OnToolActivateAsync(bool active)
{
return base.OnToolActivateAsync(active);
}
protected override async Task<bool> OnSketchModifiedAsync()
{
var sketchGeom = await GetCurrentSketchAsync();
if (sketchGeom is Multipoint multiPoint)
{
var ptCount = multiPoint.Points.Count;
// force the sketch to finish if there are more than 2 points
if (ptCount >= 2)
FinishSketchAsync();
}
return true;
}
protected override Task<bool> OnSketchCompleteAsync(Geometry geometry)
{
if (geometry is Multipoint multiPoint)
{
// check the point count
// user could have finished the sketch with less than the
// required 2 points
var ptCount = multiPoint.Points.Count;
if (ptCount < 2)
{
return Task.FromResult(true);
}
var firstPoint = multiPoint.Points[0];
var secondPoint = multiPoint.Points[1];
// first point for leader line location
// second point for callout location
}
return base.OnSketchCompleteAsync(geometry);
}
}
Narelle