I have a map project with some business layers that my users want to edit. For that, the users sometimes need to sketch a support line in a temporary layer. When they are satisfied with the support line, they edit objects in the business layers by tracing along the support line. It sounds like a backwards way of doing things, I know, but it actually makes sense, when the edits you are doing are complex, and sometimes depends on a lot of different background data.
Now, my problem is, that I want to activate the construction tool for the support layer by the click of a button. I don't want the user to go into the Create Features tab, and activate it there. Actually, I'd prefer to hide the Create Features tab entirely by configuration, but I can only do that if I can activate construction in code. However, I haven't been able to find examples on how to do this. So now, i turn to you, dear colleagues, in the hope that you can help me.
Solved! Go to Solution.
I found the solution. Maybe someone can use it in the future:
private void ActivateConstructionTool(string targetLayerName)
{
QueuedTask.Run(() =>
{
var map = ArcGIS.Desktop.Mapping.MapView.Active.Map;
if (map == null)
return;
foreach (Layer layer in map.GetLayersAsFlattenedList())
{
if (layer.Name.Equals(targetLayerName))
{
var myTemplates = layer.GetTemplates();
var myTemplate = myTemplates.ToList()[0];
myTemplate.ActivateDefaultToolAsync();
break;
}
}
});
}
I found the solution. Maybe someone can use it in the future:
private void ActivateConstructionTool(string targetLayerName)
{
QueuedTask.Run(() =>
{
var map = ArcGIS.Desktop.Mapping.MapView.Active.Map;
if (map == null)
return;
foreach (Layer layer in map.GetLayersAsFlattenedList())
{
if (layer.Name.Equals(targetLayerName))
{
var myTemplates = layer.GetTemplates();
var myTemplate = myTemplates.ToList()[0];
myTemplate.ActivateDefaultToolAsync();
break;
}
}
});
}