ArcGIS Desktop

  • 文档
  • 支持

  • My Profile
  • 帮助
  • Sign Out
ArcGIS Desktop

ArcGIS Online

专为贵组织打造的制图平台

ArcGIS Desktop

全面的专业性 GIS

ArcGIS Enterprise

面向企业的 GIS

ArcGIS for Developers

用于构建位置感知应用程序的工具

ArcGIS Solutions

适用于行业的免费模板地图和应用程序

ArcGIS Marketplace

获取适用于组织的应用程序和数据

  • 文档
  • 支持
Esri
  • 登录
user
  • 我的个人资料
  • 登出

ArcMap

  • 主页
  • 入门
  • 地图
  • 分析
  • 管理数据
  • 工具
  • 扩展模块

StyleItem

  • 摘要
  • 说明
  • 属性
  • 代码示例

摘要

可以对 StyleItem 类属性进行访问。

说明

您所选择的用于显示地图中的要素、元素或图形的符号都存储在样式文件 (.style) 中。您可以使用样式管理器 对话框来创建、查看和修改样式及其内容。样式被组织为一组预定义的类别或文件夹,例如颜色、图例项、标记符号和比例尺。单个样式项目存储在具体的类别或文件夹中。例如,图例项文件夹包含了多个不同的图例项样式项目,每个项目具有不同的格式、字号和字型,对应于图例项中显示的不同元素。

引入的 StyleItem 类可满足基本的 arcpy.mapping 要求,以便可以使用自定义设置更新图例项样式项目。在用户界面中,当您向内容列表中添加一个新的图层并且该要素被自动添加到图例中时,将应用默认样式。通过 arcpy.mapping 模块,您可以在 LegendElement 中更新页面布局的各图例项样式项目。具体可通过以下工作流实现。

  • 使用样式管理器 制作一个自定义图例项样式项目。
  • 使用 ListStyleItems 函数引用该自定义图例项样式项目。
  • 使用 ListLayoutElements 函数引用图例元素。
  • 使用 LegendElement 类中的 updateItem 方法更新图例中特定的图例项样式项目。

属性

属性说明数据类型
itemName
(只读)

A string that represents the name of the item the way it appears in the Style Manager dialog box window.

String
itemCategory
(只读)

A string that represents the category of the item the way it appears in the Style Manager dialog box window. Categories are used to group symbols within a style.

String
styleFolderName
(只读)

A string that represents the name of the folder the StyleItem is stored in, for example, Legend Items. Identifying the styleFolderName allows you to determine the type of the style object you have referenced.

String

代码示例

StyleItem 示例

以下脚本将使用上述工作流程并更新图例的图例项样式。将向地图文档中的第一个数据框添加一个图层,并通过名为 NewDefaultLegendStyle 的自定义图例项样式项目更新该图例项样式项目。自定义 .style 文件保存在用户配置文件所在的位置中。

import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
df = arcpy.mapping.ListDataFrames(mxd)[0]
lyrFile = arcpy.mapping.Layer(r"C:\Project\Data\Rivers.lyr")
arcpy.mapping.AddLayer(df, lyrFile, "TOP")
lyr = arcpy.mapping.ListLayers(mxd, 'Rivers', df)[0]
styleItem = arcpy.mapping.ListStyleItems("USER_STYLE", "Legend Items", "NewDefaultLegendStyle")[0]
legend = arcpy.mapping.ListLayoutElements(mxd, "LEGEND_ELEMENT")[0]
legend.updateItem(lyr, styleItem)
del mxd

ArcGIS Desktop

  • 主页
  • 文档
  • 支持

ArcGIS 平台

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

关于 Esri

  • 关于我们
  • 招贤纳士
  • 内部人员博客
  • 用户大会
  • 开发者峰会
Esri
分享您的想法。
© Copyright 2016 Environmental Systems Research Institute, Inc. | 隐私政策 | 法律声明