ArcGIS Pro二次开发-创建图层
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using ArcGIS.Core.CIM; using ArcGIS.Core.Data; using ArcGIS.Core.Geometry; using ArcGIS.Desktop.Catalog; using ArcGIS.Desktop.Core; using ArcGIS.Desktop.Editing; using ArcGIS.Desktop.Extensions; using ArcGIS.Desktop.Framework; using ArcGIS.Desktop.Framework.Contracts; using ArcGIS.Desktop.Framework.Dialogs; using ArcGIS.Desktop.Framework.Threading.Tasks; using ArcGIS.Desktop.Mapping; using ArcGIS.Desktop.Core.Geoprocessing; namespace ProAppModule1 { internal class Button2 : Button { public enum EnumFeatureClassType { POINT, MULTIPOINT, POLYLINE, POLYGON } public static async Task CreateFeatureClass(string featureclassName, EnumFeatureClassType featureclassType, SpatialReference pSpatialReference) { List<object> arguments = new List<object> { // store the results in the default geodatabase CoreModule.CurrentProject.DefaultGeodatabasePath, // name of the feature class featureclassName, // type of geometry featureclassType.ToString(), // no template "", // no z values "DISABLED", // no m values "DISABLED" }; await QueuedTask.Run(() => { // spatial reference // arguments.Add(SpatialReferenceBuilder.CreateSpatialReference(3857)); arguments.Add(pSpatialReference); }); IGPResult result = await Geoprocessing.ExecuteToolAsync("CreateFeatureclass_management", Geoprocessing.MakeValueArray(arguments.ToArray())); } protected override async void OnClick() { var mv = MapView.Active; SpatialReference pSpatialReference= mv.Map.SpatialReference; EnumFeatureClassType featureclassType = EnumFeatureClassType.POLYGON; string featureclassName = "gisoracle"; await CreateFeatureClass(featureclassName, featureclassType, pSpatialReference); // } } }