1. 程式人生 > 其它 >ArcGIS Pro刪除所有註記

ArcGIS Pro刪除所有註記

protected override async void OnClick()
{
  var activeMap = MapView.Active?.Map;
  if (activeMap == null) return;
  var location = @"C:/Data/FeatureTest/FeatureTest.gdb";
  var name = @"TestLinesAnno";

  await QueuedTask.Run(() =>
  {
    List<Layer> layersToRemove = new List<Layer>();
    
foreach (AnnotationLayer annotationLayer in activeMap.GetLayersAsFlattenedList().OfType<AnnotationLayer>()) { using (AnnotationFeatureClass featureClass = annotationLayer.GetFeatureClass() as AnnotationFeatureClass) { if (featureClass != null) { using (var
dataStore = featureClass.GetDatastore()) { if (dataStore.GetPath().AbsolutePath == location && featureClass.GetName() == name) { layersToRemove.Add(annotationLayer); } } } } } activeMap.RemoveLayers(layersToRemove); }); }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍