Skip to main content

createBookmark

汇总

MapView 类旨在用于两个工作流中。 首先,它可以用于 ArcGIS Pro 工程中以访问当前活动的地图视图。 其次,可以在 web 地图打印应用程序中将其与 ConvertWebMapToArcGISProject 配合使用,以访问要打印或导出的地图视图。

讨论

在 ArcGIS Pro 工程中, MapView 类可用于获取对活动地图视图的访问权限。 如果地图视图处于活动状态,则 ArcGISProject 类中的 activeView 属性将返回 MapView 对象,如果布局视图或报表视图处于活动状态,则其将返回 LayoutReport 对象。 任何其他类型的视图都会返回 NoneactiveView 属性适用于要在 ArcGIS Pro 应用程序中执行的脚本,例如在 Python 窗格中运行的脚本或者与 脚本工具 相关联的脚本。

activeView 属性返回的 MapView 是更改与视图相关联的 照相机 范围的主要方法。 还可以在调用 openView 方法之前在 Map 对象上更改 defaultCamera 属性,新打开的视图将采用这些照相机设置。 ArcGISProject 类具有 closeViews 方法,用于在打开视图之前关闭不必要的视图,从而更集中地查看该视图。

MapView 类也可以用于 web 地图打印 工作流。 MapView 类可提供对地图视图的访问权限,以便打印或导出不包含页面布局周围要素(例如,标题、图例和比例尺)的 web 地图。 这通常由正在创建 Web 地图打印应用程序的 Web 应用程序开发人员使用。 有关详细信息,请参阅 ConvertWebMapToArcGISProject

注意:

并非所有 MapView 方法均适用于 web 应用程序开发人员。 Web 地图打印应用程序中不支持以下方法:

  • getLayerExtent

  • panToExtent

  • zoomToAllLayers

  • zoomToBookmark

语法

createBookmark()

属性

名称 说明 数据类型

camera

(读取和写入)

Camera 属性用于控制数据在地图视图中显示的位置和查看位置。可以更改照相机属性,例如范围。

Camera

map

(只读)

MapView 相关联的 地图

Map

方法

createBookmark({name}, {description})

createBookmark 方法可使用当前相机设置为与地图视图相关联的 地图 创建 书签

名称 说明 数据类型

name

(可选)

An optional string that represents the name of the new bookmark. If a name is not provided, the default name value will follow the sequencing nomenclature, for example, Bookmark, Bookmark [1], Bookmark [2], and so on.

String

description

(可选)

An optional string that represents the bookmark's description.

(默认值为 Map)

String

返回值

数据类型 说明

Bookmark

书签 对象。

export(export_format, {display_options})

export 方法可使用指定 export_format 导出 MapView

名称 说明 数据类型

export_format

The supported export format objects are: AIXFormat, BMPFormat, EMFFormat, EPSFormat, GIFFormat, JPEGFormat, PDFFormat, PNGFormat, SVGFormat, TGAFormat and TIFFFormat.

Object

display_options

(可选)

The DisplayOptions object includes antialiasing mode options.

Object

exportToAIX(out_aix, width, height, {resolution}, {image_quality}, {compress_vector_graphics}, {image_compression}, {jpeg_compression_quality}, {embed_fonts}, {embed_color_profile}, {convert_markers})

将 MapView 导出为 Adobe Illustrator Exchange (AIX) 格式。 可在 ArcGIS Maps for Adobe Creative Cloud 扩展模块或 Adobe Illustrator 中使用 AIX 文件。

旧版本:

此方法在 ArcGIS Pro 3.4 中已被 export 取代,保留此方法仅供旧版脚本使用。 所有增强功能和未来开发将仅针对导出方法。

名称 说明 数据类型

out_aix

A string that represents the path and file name for the output export file.

String

width

A number that defines the width of the export in pixels.

Integer

height

A number that defines the height of the export in pixels.

Integer

resolution

(可选)

A number that defines the resolution of the export file in dots per inch (dpi).

(默认值为 300)

Integer

image_quality

(可选)

A string that specifies output image quality, the draw resolution of map layers that draw as rasters.

  • BEST—An output image quality resample ratio of 1

  • BETTER—An output image quality resample ratio of 2

  • NORMAL—An output image quality resample ratio of 3

  • FASTER—An output image quality resample ratio of 4

  • FASTEST—An output image quality resample ratio of 5

(默认值为 BEST)

String

compress_vector_graphics

(可选)

A Boolean that controls compression of vector and text portions of the output file. Image compression is defined separately.

(默认值为 True)

Boolean

image_compression

(可选)

A string that specifies the compression scheme used to compress image or raster data in the output file.

  • ADAPTIVE—Automatically selects the best compression type for each image on the page. JPEG will be used for large images with many unique colors. DEFLATE will be used for all other images.

  • DEFLATE—A lossless data compression.

  • JPEG—A lossy data compression.

  • JPEG2000—Offers higher quality compression with smaller file size than JPEG. This compression is lossless if jpeg_compression_quality is set to 100.

  • LZW—Lempel-Ziv-Welch, a lossless data compression.

  • NONE—Compression is not applied.

  • RLE—Run-length encoded compression.

(默认值为 ADAPTIVE)

String

jpeg_compression_quality

(可选)

A number that controls compression quality value when image_compression is set to ADAPTIVE or JPEG. The valid range is 1 through 100. A jpeg_compression_quality of 100 provides the best quality images but creates large export files. The recommended range is between 70 and 90.

(默认值为 80)

Integer

embed_fonts

(可选)

A Boolean that controls the embedding of fonts in the export file. Font embedding allows text and character markers to be displayed correctly when the document is viewed on a computer that does not have the necessary fonts installed.

(默认值为 True)

Boolean

embed_color_profile

(可选)

If set to True, color profile information is embedded in the image's metadata.

(默认值为 True)

Boolean

convert_markers

(可选)

A Boolean that controls the conversion of character-based marker symbols to polygons. This allows the symbols to appear correctly if the symbol font is not available or cannot be embedded. However, setting this parameter to True disables font embedding for all character-based marker symbols, which can result in a change in their appearance.

(默认值为 False)

Boolean

exportToBMP(out_bmp, width, height, {resolution}, {world_file}, {bmp_color_mode}, {bmp_image_compression}, {embed_color_profile})

用于将 MapView 导出为 Microsoft Windows 位图 (BMP) 格式文件。

旧版本:

此方法在 ArcGIS Pro 3.4 中已被 export 取代,保留此方法仅供旧版脚本使用。 所有增强功能和未来开发将仅针对导出方法。

名称 说明 数据类型

out_bmp

A string that represents the path and file name of the output export file.

String

width

A number that defines the width of the export in pixels.

Integer

height

A number that defines the height of the export in pixels.

Integer

resolution

(可选)

A number that defines the resolution of the export file in dots per inch (dpi).

(默认值为 96)

Integer

world_file

(可选)

If set to True, a georeferenced world file is created. The file contains pixel scale information and real-world coordinate information.

(默认值为 False)

Boolean

bmp_color_mode

(可选)

This value specifies the number of bits used to describe color.

  • 8-BIT_ADAPTIVE_PALETTE—8-bit adaptive palette

  • 8-BIT_GRAYSCALE—8-bit grayscale

  • 24-BIT_TRUE_COLOR—24-bit true color

(默认值为 24-BIT_TRUE_COLOR)

String

bmp_image_compression

(可选)

A string that specifies the compression scheme used to compress image or raster data in the output file. This option only applies to 8-bit bmp_color_mode options.

  • NONE—Compression is not applied.

  • RLE—Run-length encoded compression.

(默认值为 NONE)

String

embed_color_profile

(可选)

If set to True, color profile information is embedded in the image's metadata.

(默认值为 True)

Boolean

exportToEMF(out_emf, width, height, {resolution}, {image_quality}, {output_as_image}, {convert_markers})

将 MapView 导出为增强型图元文件 (EMF) 格式文件。

旧版本:

此方法在 ArcGIS Pro 3.4 中已被 export 取代,保留此方法仅供旧版脚本使用。 所有增强功能和未来开发将仅针对导出方法。

名称 说明 数据类型

out_emf

A string that represents the system path and file name of the output export file.

String

width

A number that defines the width of the export in pixels.

Integer

height

A number that defines the height of the export in pixels.

Integer

resolution

(可选)

A number that defines the resolution of the export file in dots per inch (dpi).

(默认值为 96)

Integer

image_quality

(可选)

A string that specifies output image quality, the draw resolution of map layers that draw as rasters.

  • BEST—An output image quality resample ratio of 1

  • BETTER—An output image quality resample ratio of 2

  • NORMAL—An output image quality resample ratio of 3

  • FASTER—An output image quality resample ratio of 4

  • FASTEST—An output image quality resample ratio of 5

(默认值为 BEST)

String

output_as_image

(可选)

If set to True, vector content can be saved as an image. Selecting this option for maps or layouts that contain vector layers with a high density of vertices can reduce the output file size. When exporting to PDF and this option is set to True, you cannot view PDF layers in the output.

(默认值为 False)

Boolean

convert_markers

(可选)

A Boolean that controls the conversion of character-based marker symbols to polygons. This allows the symbols to appear correctly if the symbol font is not available or cannot be embedded. However, setting this parameter to True disables font embedding for all character-based marker symbols, which can result in a change in their appearance.

(默认值为 False)

Boolean

exportToEPS(out_eps, width, height, {resolution}, {image_compression}, {image_quality}, {embed_fonts}, {output_as_image}, {convert_markers})

将 MapView 导出为封装 PostScript (EPS) 格式文件。

旧版本:

此方法在 ArcGIS Pro 3.4 中已被 export 取代,保留此方法仅供旧版脚本使用。 所有增强功能和未来开发将仅针对导出方法。

名称 说明 数据类型

out_eps

A string that represents the system path and file name of the output export file.

String

width

A number that defines the width of the export in pixels.

Integer

height

A number that defines the height of the export in pixels.

Integer

resolution

(可选)

A number that defines the resolution of the export file in dots per inch (dpi).

(默认值为 96)

Integer

image_compression

(可选)

A string that specifies the compression scheme used to compress image or raster data in the output file.

  • DEFLATE—A lossless data compression.

  • LZW—Lempel-Ziv-Welch, a lossless data compression.

  • NONE—Compression is not applied.

  • RLE—Run-length encoded compression.

(默认值为 DEFLATE)

String

image_quality

(可选)

A string that specifies output image quality, the draw resolution of map layers that draw as rasters.

  • BEST—An output image quality resample ratio of 1.

  • BETTER—An output image quality resample ratio of 2.

  • NORMAL—An output image quality resample ratio of 3.

  • FASTER—An output image quality resample ratio of 4.

  • FASTEST—An output image quality resample ratio of 5.

(默认值为 BEST)

String

embed_fonts

(可选)

A Boolean that controls the embedding of fonts in the export file. Font embedding allows text and character markers to be displayed correctly when the document is viewed on a computer that does not have the necessary fonts installed.

(默认值为 True)

Boolean

output_as_image

(可选)

If set to True, vector content can be saved as an image. Selecting this option for maps or layouts that contain vector layers with a high density of vertices can reduce the output file size. When exporting to PDF and this option is set to True, you cannot view PDF layers in the output.

(默认值为 False)

Boolean

convert_markers

(可选)

A Boolean that controls the conversion of character-based marker symbols to polygons. This allows the symbols to appear correctly if the symbol font is not available or cannot be embedded. However, setting this parameter to True disables font embedding for all character-based marker symbols, which can result in a change in their appearance.

(默认值为 False)

Boolean

exportToGIF(out_gif, width, height, {resolution}, {world_file}, {gif_color_mode})

用于将 MapView 导出为图形交换格式 (GIF) 文件。

旧版本:

此方法在 ArcGIS Pro 3.4 中已被 export 取代,保留此方法仅供旧版脚本使用。 所有增强功能和未来开发将仅针对导出方法。

名称 说明 数据类型

out_gif

A string that represents the system path and file name of the output export file.

String

width

A number that defines the width of the export in pixels.

Integer

height

A number that defines the height of the export in pixels.

Integer

resolution

(可选)

A number that defines the resolution of the export file in dots per inch (dpi).

(默认值为 96)

Integer

world_file

(可选)

If set to True, a georeferenced world file is created. The file contains pixel scale information and real-world coordinate information.

(默认值为 False)

Boolean

gif_color_mode

(可选)

This value specifies the number of bits used to describe color.

  • 8-BIT_ADAPTIVE_PALETTE—8-bit adaptive palette

  • 8-BIT_GRAYSCALE—8-bit grayscale

(默认值为 8-BIT_ADAPTIVE_PALETTE)

String

exportToJPEG(out_jpg, width, height, {resolution}, {world_file}, {jpeg_color_mode}, {jpeg_quality}, {embed_color_profile})

将 MapView 导出为联合图像专家组 (JPEG) 格式文件。

旧版本:

此方法在 ArcGIS Pro 3.4 中已被 export 取代,保留此方法仅供旧版脚本使用。 所有增强功能和未来开发将仅针对导出方法。

名称 说明 数据类型

out_jpg

A string that represents the path and file name of the output export file.

String

width

A number that defines the width of the export in pixels.

Integer

height

A number that defines the height of the export in pixels.

Integer

resolution

(可选)

A number that defines the resolution of the export file in dots per inch (dpi).

(默认值为 96)

Integer

world_file

(可选)

If set to True, a georeferenced world file is created. The file contains pixel scale information and real-world coordinate information. If you export a 3D map frame, this parameter will be ignored regardless of the setting, because world files are not applicable to 3D views.

(默认值为 False)

Boolean

jpeg_color_mode

(可选)

This value specifies the number of bits used to describe color.

  • 8-BIT_GRAYSCALE—8-bit grayscale

  • 24-BIT_TRUE_COLOR—24-bit true color

(默认值为 24-BIT_TRUE_COLOR)

String

jpeg_quality

(可选)

This value (0–100) controls the amount of compression applied to the output image. For JPEG, image quality is adversely affected the more compression is applied. A higher quality (highest = 100) setting will produce sharper images and larger file sizes. A lower quality setting will produce more image artifacts and smaller files.

(默认值为 80)

Integer

embed_color_profile

(可选)

If set to True, color profile information is embedded in the image's metadata.

(默认值为 True)

Boolean

exportToPDF(out_pdf, width, height, {resolution}, {image_quality}, {compress_vector_graphics}, {image_compression}, {embed_fonts}, {layers_attributes}, {georef_info}, {jpeg_compression_quality}, {output_as_image}, {embed_color_profile}, {convert_markers}, {simulate_overprint})

用于将 MapView 导出为便携式文档格式 (PDF) 文件。

旧版本:

此方法在 ArcGIS Pro 3.4 中已被 export 取代,保留此方法仅供旧版脚本使用。 所有增强功能和未来开发将仅针对导出方法。

名称 说明 数据类型

out_pdf

A string that represents the path and file name of the output export file.

String

width

A number that defines the width of the export in pixels.

Integer

height

A number that defines the height of the export in pixels.

Integer

resolution

(可选)

A number that defines the resolution of the export file in dots per inch (dpi).

(默认值为 300)

Integer

image_quality

(可选)

A string that defines the output image quality and the draw resolution of map layers that draw as rasters.

  • BEST—An output image quality resample ratio of 1

  • BETTER—An output image quality resample ratio of 2

  • NORMAL—An output image quality resample ratio of 3

  • FASTER—An output image quality resample ratio of 4

  • FASTEST—An output image quality resample ratio of 5

(默认值为 BEST)

String

compress_vector_graphics

(可选)

A Boolean that controls the compression of vector and text portions of the output file. Image compression is defined separately.

(默认值为 True)

Boolean

image_compression

(可选)

A string that defines the compression scheme used to compress image or raster data in the output file.

  • ADAPTIVE—Automatically selects the best compression type for each image on the page. JPEG will be used for large images with many unique colors. DEFLATE will be used for all other images.

  • DEFLATE—A lossless data compression.

  • JPEG—A lossy data compression.

  • JPEG2000—Offers higher quality compression with smaller file size than JPEG. This compression is lossless if jpeg_compression_quality is set to 100.

  • LZW—Lempel-Ziv-Welch, a lossless data compression.

  • NONE—Compression is not applied.

  • RLE—Run-length encoded compression.

(默认值为 ADAPTIVE)

String

embed_fonts

(可选)

A Boolean that controls the embedding of fonts in the export file. Font embedding allows text and character markers to be displayed correctly when the document is viewed on a computer that does not have the necessary fonts installed.

(默认值为 True)

Boolean

layers_attributes

(可选)

A string that controls the inclusion of PDF layers and PDF object data (attributes) in the export file.

  • LAYERS_ONLY—Export PDF layers only.

  • LAYERS_AND_ATTRIBUTES—Export PDF layers and feature attributes.

  • NONE—None.

(默认值为 LAYERS_ONLY)

String

georef_info

(可选)

A Boolean that enables the export of coordinate system information for each data frame into the output PDF file.

(默认值为 True)

Boolean

jpeg_compression_quality

(可选)

A number that controls the compression quality value when image_compression is set to ADAPTIVE or JPEG. The valid range is 1 through 100. A jpeg_compression_quality of 100 provides the best quality images but creates large export files. The recommended range is 70 through 90.

(默认值为 80)

Integer

output_as_image

(可选)

If set to True, vector content can be saved as an image. Selecting this option for maps or layouts that contain vector layers with a high density of vertices can reduce the output file size. When exporting to PDF and this option is set to True, you cannot view PDF layers in the output.

(默认值为 False)

Boolean

embed_color_profile

(可选)

If set to True, color profile information is embedded in the image's metadata.

(默认值为 True)

Boolean

convert_markers

(可选)

A Boolean that controls the conversion of character-based marker symbols to polygons. This allows the symbols to appear correctly if the symbol font is not available or cannot be embedded. However, setting this parameter to True disables font embedding for all character-based marker symbols, which can result in a change in their appearance.

(默认值为 False)

Boolean

simulate_overprint

(可选)

Sometimes called soft proofing, simulating overprinting shows a representation of how overlapping areas of ink will appear when printed on a page. You set up overprinting on symbol layers.

(默认值为 False)

Boolean

exportToPNG(out_png, width, height, {resolution}, {world_file}, {color_mode}, {embed_color_profile})

将 MapView 导出为便携式网络图形 (PNG) 格式文件。

旧版本:

此方法在 ArcGIS Pro 3.4 中已被 export 取代,保留此方法仅供旧版脚本使用。 所有增强功能和未来开发将仅针对导出方法。

名称 说明 数据类型

out_png

A string that represents the path and file name of the output export file.

String

width

A number that defines the width of the export in pixels.

Integer

height

A number that defines the height of the export in pixels.

Integer

resolution

(可选)

A number that defines the resolution of the export file in dots per inch (dpi).

(默认值为 96)

Integer

world_file

(可选)

If set to True, a georeferenced world file is created. The file contains pixel scale information and real-world coordinate information. If you export a 3D map frame, this parameter will be ignored regardless of the setting, because world files are not applicable to 3D views.

(默认值为 False)

Boolean

color_mode

(可选)

This value specifies the number of bits used to describe color.

  • 8-BIT_ADAPTIVE_PALETTE—8-bit adaptive palette

  • 8-BIT_GRAYSCALE—8-bit grayscale

  • 24-BIT_TRUE_COLOR—24-bit true color

  • 32-BIT_WITH_ALPHA—32-bit with alpha

(默认值为 32-BIT_WITH_ALPHA)

String

embed_color_profile

(可选)

If set to True, color profile information is embedded in the image's metadata.

(默认值为 True)

Boolean

exportToSVG(out_svg, width, height, {resolution}, {compress_to_svgz}, {image_quality}, {embed_fonts}, {output_as_image}, {convert_markers})

将 MapView 导出为可伸缩矢量图形 (SVG) 格式文件。

旧版本:

此方法在 ArcGIS Pro 3.4 中已被 export 取代,保留此方法仅供旧版脚本使用。 所有增强功能和未来开发将仅针对导出方法。

名称 说明 数据类型

out_svg

A string that represents the path and file name of the output export file.

String

width

A number that defines the width of the export in pixels.

Integer

height

A number that defines the height of the export in pixels.

Integer

resolution

(可选)

A number that defines the resolution of the export file in dots per inch (dpi).

(默认值为 96)

Integer

compress_to_svgz

(可选)

If set to True, the output is compressed.

(默认值为 False)

Boolean

image_quality

(可选)

A string that specifies output image quality, the draw resolution of map layers that draw as rasters.

  • BEST—An output image quality resample ratio of 1.

  • BETTER—An output image quality resample ratio of 2.

  • NORMAL—An output image quality resample ratio of 3.

  • FASTER—An output image quality resample ratio of 4.

  • FASTEST—An output image quality resample ratio of 5.

(默认值为 BEST)

String

embed_fonts

(可选)

A Boolean that controls the embedding of fonts in the export file. Font embedding allows text and character markers to be displayed correctly when the document is viewed on a computer that does not have the necessary fonts installed.

(默认值为 True)

Boolean

output_as_image

(可选)

If set to True, vector content can be saved as an image. Selecting this option for maps or layouts that contain vector layers with a high density of vertices can reduce the output file size. When exporting to PDF and this option is set to True, you cannot view PDF layers in the output.

(默认值为 False)

Boolean

convert_markers

(可选)

A Boolean that controls the conversion of character-based marker symbols to polygons. This allows the symbols to appear correctly if the symbol font is not available or cannot be embedded. However, setting this parameter to True disables font embedding for all character-based marker symbols, which can result in a change in their appearance.

(默认值为 False)

Boolean

exportToTGA(out_tga, width, height, {resolution}, {world_file}, {color_mode})

用于将 MapView 导出为 Truevision 图形适配器 (TGA) 格式文件。

旧版本:

此方法在 ArcGIS Pro 3.4 中已被 export 取代,保留此方法仅供旧版脚本使用。 所有增强功能和未来开发将仅针对导出方法。

名称 说明 数据类型

out_tga

A string that represents the path and file name of the output export file.

String

width

A number that defines the width of the export in pixels.

Integer

height

A number that defines the height of the export in pixels.

Integer

resolution

(可选)

A number that defines the resolution of the export file in dots per inch (dpi).

(默认值为 96)

Integer

world_file

(可选)

If set to True, a georeferenced world file is created. The file contains pixel scale information and real-world coordinate information.

(默认值为 False)

Boolean

color_mode

(可选)

This value specifies the number of bits used to describe color.

  • 8-BIT_ADAPTIVE_PALETTE—8-bit adaptive palette

  • 8-BIT_GRAYSCALE—8-bit grayscale

  • 24-BIT_TRUE_COLOR—24-bit true color

  • 32-BIT_WITH_ALPHA—32-bit with alpha

(默认值为 32-BIT_WITH_ALPHA)

String

exportToTIFF(out_tif, width, height, {resolution}, {world_file}, {color_mode}, {tiff_compression}, {geoTIFF_tags}, {jpeg_compression_quality}, {embed_color_profile})

将 MapView 导出为标记图像文件格式 (TIFF) 文件。

旧版本:

此方法在 ArcGIS Pro 3.4 中已被 export 取代,保留此方法仅供旧版脚本使用。 所有增强功能和未来开发将仅针对导出方法。

名称 说明 数据类型

out_tif

A string that represents the path and file name of the output export file.

String

width

A number that defines the width of the export in pixels.

Integer

height

A number that defines the height of the export in pixels.

Integer

resolution

(可选)

A number that defines the resolution of the export file in dots per inch (dpi).

(默认值为 96)

Integer

world_file

(可选)

If set to True, a georeferenced world file is created. The file contains pixel scale information and real-world coordinate information. If you export a 3D map frame, this parameter will be ignored regardless of the setting, because world files are not applicable to 3D views.

(默认值为 False)

Boolean

color_mode

(可选)

This value specifies the number of bits used to describe color. The available options are dependent on the specified Color Model set in the layout's Color Management properties.

  • 8-BIT_ADAPTIVE_PALETTE—8-bit adaptive palette. Available to RGB and CMYK.

  • 8-BIT_GRAYSCALE—8-bit grayscale. Available to RGB and CMYK.

  • 24-BIT_TRUE_COLOR—24-bit true color. Available only to RGB.

  • 32-BIT_WITH_ALPHA—32-bit with alpha. Available only to RGB.

  • 32-BIT_CMYK_TRUE_COLOR—32-bit CMYK true color. Available only to CMYK.

  • 40-BIT_CMYK_WITH_ALPHA—40-bit CMYK with alpha. Available only to CMYK.

(默认值为 24-BIT_TRUE_COLOR)

String

tiff_compression

(可选)

This value represents a compression scheme.

  • DEFLATE—A lossless data compression.

  • JPEG—JPEG compression.

  • LZW—Lempel-Ziv-Welch, a lossless data compression.

  • NONE—Compression is not applied.

  • PACK_BITS—Pack bits compression.

(默认值为 LZW)

String

geoTIFF_tags

(可选)

If set to True, georeferencing tags are included in the structure of the TIFF export file. The tags contain pixel scale information and real-world coordinate information. These tags can be read by applications that support the GeoTIFF format.

(默认值为 False)

Boolean

jpeg_compression_quality

(可选)

This value (0–100) controls the amount of compression applied to the output image. With a JPEG image, quality is adversely affected the more compression is applied. A higher quality (highest = 100) setting will produce sharper images and larger file sizes. A lower quality setting will produce more image artifacts and smaller files.

(默认值为 80)

Integer

embed_color_profile

(可选)

If set to True, color profile information is embedded in the image's metadata.

(默认值为 True)

Boolean

getLayerExtent(layer, {selection_only}, {symbolized_extent})

返回图层中所有要素或仅仅所选要素的图层范围。

名称 说明 数据类型

layer

引用 Layer 对象。

Layer

selection_only

(可选)

如果为 True ,将返回选定要素的范围;如果为 False ,将返回所有要素的范围。

(默认值为 True)

Boolean

symbolized_extent

(可选)

如果值为 True ,将返回图层的符号化范围;否则将返回几何范围。符号化范围会将符号覆盖的区域考虑在内,因此该区域不会被数据框边界切掉。

(默认值为 True)

Boolean

返回值

数据类型 说明

Extent

地理处理 Extent 对象。

panToExtent(extent)

使用新 Extent 对象可平移和居中 MapView ,而无需更改地图视图的比例。

名称 说明 数据类型

extent

地理处理 Extent 对象。

Extent

zoomToAllLayers({selection_only}, {symbolized_extent})

修改 MapView 视图以便与所有图层或地图中所选图层的范围相匹配。

名称 说明 数据类型

selection_only

(可选)

如果为 True ,将根据选定要素设置范围;如果为 False ,将为地图中的所有要素设置范围。

(默认值为 True)

Boolean

symbolized_extent

(可选)

如果值为 True ,将返回图层的符号化范围;否则将返回几何范围。符号化范围会将符号覆盖的区域考虑在内,因此该区域不会被地图框边界切掉。

(默认值为 True)

Boolean

zoomToBookmark(bookmark)

修改 MapView 视图以便与通过空间书签存储的视图信息相匹配。

名称 说明 数据类型

bookmark

引用 Bookmark 对象。

Bookmark

代码示例

活动地图视图示例

在本示例中,将 MapView 范围导出到 PNG 文件之前,将针对当前活动地图视图对其进行修改。 可以使用 current 关键词来引用 ArcGIS Pro 工程。 此脚本将在 Python 窗格或 脚本工具 中运行。

import arcpy, os

aprx = arcpy.mp.ArcGISProject('current')
mv = aprx.activeView

# Change the extent of the map view
ext = mv.camera.getExtent()
ext.XMin = ext.XMin + 100
ext.YMin = ext.YMin + 100
ext.XMax = ext.XMax - 100
ext.YMax = ext.YMax - 100
mv.camera.setExtent(ext)

# Export the map view
Output_File = os.path.join(arcpy.env.scratchFolder, 'ActiveMapView.png')
mv.exportToPNG(Output_File, width=1000, height=1000, world_file=True, color_mode="32-BIT_WITH_ALPHA")
MapView 网络地图打印示例

在本示例中,脚本在 Web 地图 JSON 中读取。 ConvertWebMapToArcGISProject 中的输出 MapView 将导出为 PNG 文件。

import arcpy
import os
import uuid

# Input web map json
Web_Map_as_JSON = arcpy.GetParameterAsText(0)

# Convert the web map to an ArcGIS Project
result = arcpy.mp.ConvertWebMapToArcGISProject(Web_Map_as_JSON)
aprx = result.ArcGISProject

# Get the map view
m = aprx.listMaps()[0]
mv = m.defaultView

# Use the uuid module to generate a GUID as part of the output name
# This will ensure a unique output name
output = 'WebMap_{}.png'.format(str(uuid.uuid1()))
Output_File = os.path.join(arcpy.env.scratchFolder, output)

# Export the web map
mv.exportToPNG(Output_File, result.outputSizeWidth, result.outputSizeHeight, result.DPI)

# Set the output parameter to be the output file of the server job
arcpy.SetParameterAsText(1, Output_File)

# Clean up
del mv, m, aprx, result
CreateMap 和打开地图视图示例

下面的脚本使用了关键字 current,因此可从 Python 窗口运行此脚本。 该脚本用于新建地图并向其添加新图层。 将更新地图的默认照相机属性,该属性用于控制新打开的视图的范围。 然后将地图视图导出为 PDF。 新建的地图随即从工程中移除。

aprx = arcpy.mp.ArcGISProject("CURRENT")

#Create a copy of an existing map
newMap = aprx.createMap("Ranger Stations", "Map")

#Add ranger stations layer file
lyrx1 = arcpy.mp.LayerFile(r"C:\Projects\YosemiteNP\LayerFiles\Park Boundary.lyrx")
newMap.addLayer(lyrx1)
lyrx2 = arcpy.mp.LayerFile(r"C:\Projects\YosemiteNP\LayerFiles\Ranger Stations.lyrx")
newMap.addLayer(lyrx2)

#Close any current map or layout views
aprx.closeViews("MAPS_AND_LAYOUTS")

#Set the default map camera to the extent of the park boundary before opening the new view
#default camera only affects newly opened views
lyr = newMap.listLayers("*Park Boundary")[-1]
newMap.defaultCamera.setExtent(arcpy.Describe(lyr).extent)
newMap.openView()

#export the newly opened active view to PDF, then delete the new map
mv = aprx.activeView
mv.exportToPDF(r"C:\Temp\RangerStations.pdf", width=700, height=500, resolution=96)
aprx.deleteItem(newMap)