【ArcGIS Pro二次开发】(57):地图系列

在ArcGIS Pro中,有一个地图系列,可以在一个布局中导出多个地图。

在SDK中为ArcGIS.Desktop.layout.MapSeries类和映射系列导出选项,可以以支持多页导出。

MapSeries类提供了一个静态CreateSpatialMapSeries方法,该方法使用指定的索引层(作为参数传递)为给定布局生成空间地图系列。

使用返回的SpatialMapSeries类实例可以细化地图系列格式选项(范围选项、边距设置等)。

与布局关联的地图系列(如果有)可以从其【layout.MapSeries】属性中访问。


1、创建地图系列

cs 复制代码
  await QueuedTask.Run(() =>
  {
     // 地图系列构造函数【布局,地图,视图图层,名称】
     var SMS = MapSeries.CreateSpatialMapSeries(layout, mapFrame, countiesLayer, "新地图系列");
  
     // SMC参数
     SMS.CategoryField = "State";
     SMS.SortField = "Population";
     SMS.ExtentOptions = ExtentFitType.BestFit;
     SMS.MarginType = ArcGIS.Core.CIM.UnitType.PageUnits;
     SMS.MarginUnits = ArcGIS.Core.Geometry.LinearUnit.Centimeters;
     SMS.Margin = 1;

     // 创建地图系列
     layout.SetMapSeries(SMS);
  });

**2、**导出地图系列

要导出地图系列,可以将MapSeriesExportOptions类与ExportFormat结合使用以创建多页导出。对于PDF和TIFF,可以将地图系列导出为单个文件,每个地图页导出一个,也可以导出为包含所有(指定)地图页的单个多页(或多图像)文件。对于所有其他导出格式,单独的页面将作为单独的文件导出。

下面以导出多页PDF为例:

cs 复制代码
// 将具有多个页面的地图系列从活动布局导出为单个PDF
var layout = LayoutView.Active.Layout;
if (layout == null) return;

// 设置输出路径
var pdf = @"C:\Users\Administrator\Desktop\States.pdf";
if (File.Exists(pdf)) { File.Delete(pdf); }

// 设置导出的PDF图片格式
var exportFormat = new PDFFormat()
{
    OutputFileName = pdf,
    Resolution = 300,
    DoCompressVectorGraphics = true,
    DoEmbedFonts = true,
    HasGeoRefInfo = true,
    ImageCompression = ImageCompression.Adaptive,
    ImageQuality = ImageQuality.Better,
    LayersAndAttributes = LayersAndAttributes.LayersAndAttributes
};

// // 设置地图系列的导出方式
var mapSeriesExportOptions = new MapSeriesExportOptions()
{
    // 导出内容,包括【All, Current, SelectedIndexFeatures】
    ExportPages = ExportPages.Custom,
    CustomPages = "1-3",
    // 导出单个PDF,也可以按名称导出多个PDF
    ExportFileOptions = ExportFileOptions.ExportAsSinglePDF,
};

// 检查路径是否有效,导出PDF
if (exportFormat.ValidateOutputFilePath())
{
    layout.Export(exportFormat, mapSeriesExportOptions);
}
相关推荐
小白不白11116 小时前
C# WinForm 与 VP 二次开发
开发语言·c#
SunnyDays101117 小时前
如何使用 C# 自动调整 Excel 行高和列宽
开发语言·c#·excel
itgather18 小时前
OfficeExcel — Word / Excel DLL 验证台功能介绍
c#·word·excel
云中小生18 小时前
Scrutor:.NET 依赖注入自动化的优雅实现
c#·.net
郝亚军18 小时前
Visual Studio 2022项目中的.sln是什么?
c++·c#·visual studio
jghhh0118 小时前
C# 图片水印工具(支持9个位置)
数据库·microsoft·c#
咸鱼翻身小阿橙19 小时前
C# WinForms 控件学习项目
开发语言·学习·c#
JaydenAI19 小时前
[MAF预定义Agent中间件-03]FunctionInvocationDelegatingAgent:将AOP引入函数调用
ai·c#·agent·aop·maf
.NET修仙日记19 小时前
.NET 领域驱动设计:用户角色更新如何从应用服务落地到领域实体(代码拆解)
c#·.net·领域驱动设计·微软技术·角色设计
.NET修仙日记19 小时前
Scrutor:.NET 依赖注入自动化的优雅实现
c#·.net·.net core·微软技术·依赖注入·scrutor