MapView

Zusammenfassung

The MapView class is intended to be used in two workflows. Firstly, it can be used in an ArcGIS Pro project to access the currently active map view. Secondly, it can be used in conjunction with ConvertWebMapToArcGISProject in a web map printing application to access a map view to print or export.

Diskussion

The MapView class can be used to gain access to the active map view in an ArcGIS Pro project. The activeView property from the ArcGISProject class will either return a MapView object if a map view is active or it will return a Layout object if a layout view is active. Any other type of view will return None. The activeView property is intended for scripts that are to be executed in the ArcGIS Pro application, such as scripts run in the Python pane or those associated with a script tool. The MapView returned from the activeView property is the only way to change the extent of the Camera associated with a map view.

The MapView class can also be used in web map printing workflows. The MapView class provides access to a map view to print or export a web map that doesn't contain page layout surroundings (for example, title, legends, and scale bar). This is generally used by web app developers who are creating web map printing applications. For more information, see ConvertWebMapToArcGISProject.

Vorsicht:

Not all MapView methods are available to web app developers. The following methods are not supported in a web map printing application:

  • getLayerExtent
  • panToExtent
  • zoomToAllLayers
  • zoomToBookmark

Eigenschaften

EigenschaftErläuterungDatentyp
camera
(Lesen und schreiben)

The Camera property controls the location and viewing positions of the data displayed in a map view. You can change camera properties—for example, the extent.

Camera
map
(Schreibgeschützt)

The Map associated with the MapView.

Map

Methodenübersicht

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

Exports a map frame to Adobe Creative Cloud (AIX) format.

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

Exports the map view to a Microsoft Windows Bitmap (BMP) format file.

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

Exports the page layout to an Enhanced Metafile (EMF) format file.

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

Exports the contents of a MapView to an Encapsulated PostScript (EPS) format file.

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

Exports the contents of a MapView to a Graphic Interchange Format (GIF) file.

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

Exports the contents of a MapView to a Joint Photographic Experts Group (JPEG) format file.

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})

Exports the contents of a MapView to a Portable Document Format (PDF) file.

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

Exports the contents of a MapView to a Portable Network Graphics (PNG) format file.

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

Exports the contents of a MapView to a Scalable Vector Graphics (SVG) format file.

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

Exports the map view to a Truevision Graphics Adapter (TGA) format file.

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

Exports the map view to a Tagged Image File Format (TIFF) file.

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

Returns a layer's extent for all features or only the selected features in a layer.

panToExtent (extent)

Pans and centers the MapView using a new Extent object without changing the map view's scale.

zoomToAllLayers ({selection_only}, {symbolized_extent})

Modifies the MapView view to match the extent of all layers or selected layers in a map.

zoomToBookmark (bookmark)

Modifies the MapView view to match the view information stored with a spatial bookmark.

Methoden

exportToAIX (out_aix, width, height, {resolution}, {image_quality}, {compress_vector_graphics}, {image_compression}, {jpeg_compression_quality}, {embed_fonts}, {embed_color_profile})
ParameterErläuterungDatentyp
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).

(Der Standardwert ist 300)

Integer
image_quality

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

  • BESTAn output image quality resample ratio of 1
  • BETTERAn output image quality resample ratio of 2
  • NORMALAn output image quality resample ratio of 3
  • FASTERAn output image quality resample ratio of 4
  • FASTESTAn output image quality resample ratio of 5

(Der Standardwert ist BEST)

String
compress_vector_graphics

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

(Der Standardwert ist True)

Boolean
image_compression

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

  • ADAPTIVEAutomatically 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.
  • DEFLATEA lossless data compression.
  • JPEGA lossy data compression.
  • LZWLempel-Ziv-Welch, a lossless data compression.
  • NONECompression is not applied.
  • RLERun-length encoded compression.

(Der Standardwert ist 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.

(Der Standardwert ist 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.

(Der Standardwert ist True)

Boolean
embed_color_profile

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

(Der Standardwert ist True)

Boolean

AIX is an Adobe Illustrator Exchange file exported from ArcGIS to be used with the ArcGIS Maps for Adobe Creative Cloud plug-in. When used with the plug-in, vector and raster map content is converted into editable, layered artwork for an improved editing experience in Adobe Illustrator. Once opened in Illustrator, it can be used for high-end graphic design or map finishing workflows and migrated across the other Adobe Creative Cloud applications.

exportToBMP (out_bmp, width, height, {resolution}, {world_file}, {bmp_color_mode}, {bmp_image_compression}, {embed_color_profile})
ParameterErläuterungDatentyp
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).

(Der Standardwert ist 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.

(Der Standardwert ist False)

Boolean
bmp_color_mode

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

  • 8-BIT_ADAPTIVE_PALETTE8-bit adaptive palette
  • 8-BIT_GRAYSCALE8-bit grayscale
  • 24-BIT_TRUE_COLOR24-bit true color

(Der Standardwert ist 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.

  • NONECompression is not applied.
  • RLERun-length encoded compression.

(Der Standardwert ist NONE)

String
embed_color_profile

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

(Der Standardwert ist True)

Boolean

BMP files are native Windows raster images. BMP files can store pixel data at several bit depths. BMP images are typically much larger than other formats such as JPEG or PNG.

exportToEMF (out_emf, width, height, {resolution}, {image_quality}, {output_as_image})
ParameterErläuterungDatentyp
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).

(Der Standardwert ist 96)

Integer
image_quality

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

  • BESTAn output image quality resample ratio of 1
  • BETTERAn output image quality resample ratio of 2
  • NORMALAn output image quality resample ratio of 3
  • FASTERAn output image quality resample ratio of 4
  • FASTESTAn output image quality resample ratio of 5

(Der Standardwert ist 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.

(Der Standardwert ist False)

Boolean

EMF files are native Windows graphics files that can contain a combination of vector and raster data. They are useful for embedding in Windows documents because the vector portions of the EMF file can be resized without loss of quality. However, since an EMF file does not support font embedding and is exclusively a Windows format, it is not commonly used as an interchange format between users.

exportToEPS (out_eps, width, height, {resolution}, {image_compression}, {image_quality}, {embed_fonts}, {output_as_image})
ParameterErläuterungDatentyp
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).

(Der Standardwert ist 96)

Integer
image_compression

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

  • DEFLATEA lossless data compression.
  • LZWLempel-Ziv-Welch, a lossless data compression.
  • NONECompression is not applied.
  • RLERun-length encoded compression.

(Der Standardwert ist DEFLATE)

String
image_quality

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

  • BESTAn output image quality resample ratio of 1.
  • BETTERAn output image quality resample ratio of 2.
  • NORMALAn output image quality resample ratio of 3.
  • FASTERAn output image quality resample ratio of 4.
  • FASTESTAn output image quality resample ratio of 5.

(Der Standardwert ist 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.

(Der Standardwert ist 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.

(Der Standardwert ist False)

Boolean

EPS files use the PostScript page description language to describe vector and raster objects. PostScript is the publishing industry standard for high-end graphics files, cartography, and printing. EPS files can be edited in many drawing applications or placed as a graphic in most page layout applications. EPS files support embedding of fonts so users who do not have Esri fonts installed can still view the proper symbology.

exportToGIF (out_gif, width, height, {resolution}, {world_file}, {gif_color_mode})
ParameterErläuterungDatentyp
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).

(Der Standardwert ist 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.

(Der Standardwert ist False)

Boolean
gif_color_mode

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

  • 8-BIT_PALETTE8-bit adaptive palette
  • 8-BIT_GRAYSCALE8-bit grayscale

(Der Standardwert ist 8-BIT_PALETTE)

String

GIF files are a legacy raster format for use on the web. GIF files cannot contain more than 256 colors (8 bits per pixel), which along with optional lossless compression, makes them smaller than other file formats.

exportToJPEG (out_jpg, width, height, {resolution}, {world_file}, {jpeg_color_mode}, {jpeg_quality}, {embed_color_profile})
ParameterErläuterungDatentyp
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).

(Der Standardwert ist 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.

(Der Standardwert ist False)

Boolean
jpeg_color_mode

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

  • 8-BIT_GRAYSCALE8-bit grayscale
  • 24-BIT_TRUE_COLOR24-bit true color

(Der Standardwert ist 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.

(Der Standardwert ist 80)

Integer
embed_color_profile

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

(Der Standardwert ist True)

Boolean

JPEG files are compressed image files. They support 24-bit color and are a popular choice for use on the web because a JPEG file size is often substantially smaller than many other image formats. However, the JPEG compression algorithm is lossy and is not recommended for many map images, as line drawings, and text or icon graphics, become blurred by compression artifacts. Therefore, the PNG format is usually superior for map images. JPEG files can be generated with an accompanying world file for use as georeferenced raster data.

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})
ParameterErläuterungDatentyp
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).

(Der Standardwert ist 300)

Integer
image_quality

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

  • BESTAn output image quality resample ratio of 1
  • BETTERAn output image quality resample ratio of 2
  • NORMALAn output image quality resample ratio of 3
  • FASTERAn output image quality resample ratio of 4
  • FASTESTAn output image quality resample ratio of 5

(Der Standardwert ist 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.

(Der Standardwert ist True)

Boolean
image_compression

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

  • ADAPTIVEAutomatically 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.
  • DEFLATEA lossless data compression.
  • JPEGA lossy data compression.
  • LZWLempel-Ziv-Welch, a lossless data compression.
  • NONECompression is not applied.
  • RLERun-length encoded compression.

(Der Standardwert ist 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.

(Der Standardwert ist True)

Boolean
layers_attributes

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

  • LAYERS_ONLYExport PDF layers only.
  • LAYERS_AND_ATTRIBUTESExport PDF layers and feature attributes.
  • NONENone.

(Der Standardwert ist LAYERS_ONLY)

String
georef_info

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

(Der Standardwert ist 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.

(Der Standardwert ist 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.

(Der Standardwert ist False)

Boolean
embed_color_profile

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

(Der Standardwert ist True)

Boolean

PDF files are designed to be consistently viewable and printable across different platforms. They are commonly used for distributing documents on the web, and the format is now an official ISO standard for document interchange. PDF files are editable in many graphics applications and retain map georeference information, annotation, labeling, and feature attribute data. PDF exports support embedding of fonts and can display symbology correctly even if the user does not have Esri fonts installed.

Review the PDFDocument class to learn more about how to manage PDF files, such as appending, inserting, and setting properties.

exportToPNG (out_png, width, height, {resolution}, {world_file}, {color_mode}, {embed_color_profile})
ParameterErläuterungDatentyp
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).

(Der Standardwert ist 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.

(Der Standardwert ist False)

Boolean
color_mode

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

  • 8-BIT_ADAPTIVE_PALETTE8-bit adaptive palette
  • 8-BIT_GRAYSCALE8-bit grayscale
  • 24-BIT_TRUE_COLOR24-bit true color
  • 32-BIT_WITH_ALPHA32-bit with alpha

(Der Standardwert ist 32-BIT_WITH_ALPHA)

String
embed_color_profile

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

(Der Standardwert ist True)

Boolean

The PNG format is a versatile raster format that can display in web browsers and be inserted into other documents. It supports high-bit-depth color and uses a lossless compression. For maps, PNG is often the best raster format, since the lossless compression keeps text and line work legible by preventing the compression artifacts that can occur in JPEG format. PNG files can also define a transparent color. PNG files can be generated with an accompanying world file for use as georeferenced raster data.

exportToSVG (out_svg, width, height, {resolution}, {compress_to_svgz}, {image_quality}, {embed_fonts}, {output_as_image})
ParameterErläuterungDatentyp
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).

(Der Standardwert ist 96)

Integer
compress_to_svgz

If set to True, the output is compressed.

(Der Standardwert ist False)

Boolean
image_quality

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

  • BESTAn output image quality resample ratio of 1.
  • BETTERAn output image quality resample ratio of 2.
  • NORMALAn output image quality resample ratio of 3.
  • FASTERAn output image quality resample ratio of 4.
  • FASTESTAn output image quality resample ratio of 5.

(Der Standardwert ist 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.

(Der Standardwert ist 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.

(Der Standardwert ist False)

Boolean

The SVG format is an XML-based file format that is specifically designed for viewing on the web. An SVG file can contain both vector and raster information. Some web browsers may require a plug-in to view SVG files. Older browsers may not be able to view SVG files at all. The SVG format supports the embedding of fonts so users who do not have Esri fonts installed can view SVG exports with proper symbology. You can also produce compressed SVG files. The file extension changes to .svgz when this option is enabled.

exportToTGA (out_tga, width, height, {resolution}, {world_file}, {color_mode})
ParameterErläuterungDatentyp
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).

(Der Standardwert ist 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.

(Der Standardwert ist False)

Boolean
color_mode

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

  • 8-BIT_ADAPTIVE_PALETTE8-bit adaptive palette
  • 8-BIT_GRAYSCALE8-bit grayscale
  • 24-BIT_TRUE_COLOR24-bit true color
  • 32-BIT_WITH_ALPHA32-bit with alpha

(Der Standardwert ist 32-BIT_WITH_ALPHA)

String

TGA files have historically been used for content that is meant to be used in other applications (for example, image sprites for animated games) and is read and written by many popular graphic arts applications. TGA format supports multiple bit depths including 32-bit with alpha (transparency) support.

exportToTIFF (out_tif, width, height, {resolution}, {world_file}, {color_mode}, {tiff_compression}, {geoTIFF_tags}, {jpeg_compression_quality}, {embed_color_profile})
ParameterErläuterungDatentyp
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).

(Der Standardwert ist 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.

(Der Standardwert ist False)

Boolean
color_mode

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

  • 8-BIT_ADAPTIVE_PALETTE8-bit adaptive palette
  • 8-BIT_GRAYSCALE8-bit grayscale
  • 24-BIT_TRUE_COLOR24-bit true color
  • 32-BIT_WITH_ALPHA32-bit with alpha

(Der Standardwert ist 24-BIT_TRUE_COLOR)

String
tiff_compression

This value represents a compression scheme.

  • DEFLATEA lossless data compression.
  • JPEGJPEG compression.
  • LZWLempel-Ziv-Welch, a lossless data compression.
  • NONECompression is not applied.
  • PACK_BITSPack bits compression.

(Der Standardwert ist 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.

(Der Standardwert ist 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.

(Der Standardwert ist 80)

Integer
embed_color_profile

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

(Der Standardwert ist True)

Boolean

TIFF files are the best choice for importing into image editing applications and are also a common GIS raster data format. However, they cannot be natively viewed by a web browser. TIFF files also support georeferencing information in GeoTIFF tags or in a separate world file for use as raster data.

getLayerExtent (layer, {selection_only}, {symbolized_extent})
ParameterErläuterungDatentyp
layer

A reference to a Layer object.

Layer
selection_only

If True, it returns the extent for selected features; if False, it returns the extent for all features.

(Der Standardwert ist True)

Boolean
symbolized_extent

A value of True will return the layer's symbolized extent; otherwise, it will return the geometric extent. The symbolized extent takes into account the area the symbology covers so that it does not get cut off by the data frame's boundary.

(Der Standardwert ist True)

Boolean
Rückgabewert
DatentypErläuterung
Extent

A geoprocessing Extent object.

The getLayerExtent method will honor a layer's definition query, so if a subset of features are queried, it will return the extent for only those features. If there are no selected features, the extent for the layer will be returned.

panToExtent (extent)
ParameterErläuterungDatentyp
extent

A geoprocessing Extent object.

Extent

This method is perfect for situations in which the scale should not change but the location should. Rather than setting the extent and then having to reset the scale each time, panToExtent maintains the scale and centers the camera on the new extent.

zoomToAllLayers ({selection_only}, {symbolized_extent})
ParameterErläuterungDatentyp
selection_only

If True, it sets the extent based on the selected features; if False, it sets the extent for all features in a map.

(Der Standardwert ist True)

Boolean
symbolized_extent

A value of True will return the layer's symbolized extent; otherwise, it will return the geometric extent. The symbolized extent takes into account the area the symbology covers so that it does not get cut off by the map frame's boundary.

(Der Standardwert ist True)

Boolean

If zoomToAllLayers is used on a MapView with a global or local scene, the result will be a planimetric view.

zoomToBookmark (bookmark)
ParameterErläuterungDatentyp
bookmark

A reference to a Bookmark object.

Bookmark

If a 3D bookmark is used for a MapView referencing a 2D Map, or the other way around, the result will be a planimetric view.

Codebeispiel

Active map view example

In this example, the MapView extent is modified for the currently active map view before being exported to a PNG file. The ArcGIS Pro project is referenced using the current keyword. This script is intended to be run in the Python pane or a script tool.

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 map printing example

In this example, the script reads in a web map JSON. The output MapView from ConvertWebMapToArcGISProject is exported to a PNG file.

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