ArcGIS Pro 设置要素图层样式
This tutorial demonstrates how to build an add-in that can assign a renderer to your feature layer to change feature symbology.
With the ArcGIS Pro SDK for .NET, you can extend ArcGIS Pro with your own unique tools and workflows. Using Microsoft Visual Studio and the Pro SDK, developers can build Pro add-ins and solution configurations that provide users with custom functionality, such as the ability to interact with feature layers and their symbology, specific to their organization or industry. You can update layer symbology based upon an existing system style or a custom style that is loaded within your project.
In this tutorial you will create an add-in with two buttons that update the symbology of a point feature layer with either a new symbol or graduated colors.
Tip
For more information, see the ArcGIS Pro wiki map authoring or see the ArcGIS Pro SDK API reference. You can also review the ArcGIS Pro user community's map authoring samples.
Prerequisites
- Microsoft Visual Studio is required. See the ArcGIS Pro system requirements for latest version and compatibility.
- Install ArcGIS Pro version 3.0 or higher.
- Install the ArcGIS Pro SDK for .NET. See the Installation ProGuide for more information.
- This tutorial uses Pro SDK Community sample data.
Steps
Create a new ArcGIS Pro Add-In solution
-
Start Visual Studio.
-
Choose File > New > Project and then from the ArcGIS templates group, select ArcGIS Pro Module Add-in. Name the add-in project "LayerSymbology". Click OK to proceed.
Create new Pro buttons and update DAML
-
Right-click the project and choose Add > New Item and then from the ArcGIS Pro Add-ins group select ArcGIS Pro Button from the list of item templates.
-
When prompted, name the new class file
SingleSymbol.cs
and click Add to close the dialog box. -
Repeat these steps to add a second button, naming this class
GraduatedColor.cs
. -
Add the following code to the
OnClick
method ofSingleSymbol.cs
: -
Add the following code to the
OnClick
method ofGraduatedColor.cs
: -
Update the
Config.daml
fileAddInInfo
section so that the DAML appears as follows. This updates the captions for each of the buttons, and the caption of the control group, which will appear on the Add-In tab.
Create a new method in the module file
-
Copy the following code to create a new
ApplySymbol
method, and paste it into the Module1.cs file below theOverrides
region.
Update the dataset and test the add-in
To update layer symbology to graduated colors requires a numeric attribute named Symbol
on which to apply an equal interval classification. One method is to add a new field to the previously downloaded ArcGIS Pro SDK community sample dataset, FeatureTest, which is typically located in C:\Data\FeatureTest\
.
The following steps assume that you are using this dataset for testing.
-
Build your project and resolve any issues.
-
Click Start Debugging to run your project, which will launch ArcGIS Pro. Open the FeatureTest.aprx project.
-
In the map view, find the layer named TestPoints. Add a new integer attribute named Symbol to this layer and then calculate its values to match the values in the
ObjectID
attribute.You can use the following Geoprocessing tools to add a new field and calculate values:
<https://pro.arcgis.com/en/pro-app/tool-reference/data-management/add-field.htm>
<https://pro.arcgis.com/en/pro-app/tool-reference/data-management/calculate-field.htm>
-
Once the new Symbol attribute is available and populated, from the Add-In tab find your new control group with your two new buttons. Test both of your buttons with the TestPoints point feature layer to see it rendered with either a new single symbol or graduated colors.
What's Next?
Learn how to use additional ArcGIS Pro SDK for .NET features in these tutorials:
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
2020-03-20 C#一个简单的含参数,控件调用多线程调用
2018-03-20 电脑不能使用ArcMap 提示由于系统时间不对造成的怎么办?转