用途:在 ArcGIS Maps SDK for JavaScript 中创建与自定义要素图层弹窗(PopupTemplate),组合多种内容类型展示属性与可视化信息。
主要能力:支持 TextContent、FieldsContent、MediaContent(饼图、柱状图、条形图、折线图、图片)、AttachmentsContent、ExpressionContent(Arcade)、CustomContent 与 RelationshipContent(关联记录)。可设置 title、content、fieldInfos、expressionInfos、outFields、actions、overwriteActions、returnGeometry 等属性,并使用 {fieldName} 字段替换、函数式或异步内容、Arcade 表达式、聚类弹窗与自定义操作按钮。
使用方式:可直接 ESM 导入,例如 import PopupTemplate from "@arcgis/core/PopupTemplate.js";,CDN 场景用 const PopupTemplate = await $arcgis.import("@arcgis/core/PopupTemplate.js");。基础设置如 layer.popupTemplate = { title: "{name}", content: "Population: {population}" };。操作按钮点击可通过 reactiveUtils.on(() => view.popup, "trigger-action", callback) 处理。
适用场景:要素属性展示、图表与图片呈现、附件查看、关联记录浏览、Arcade 计算字段展示及聚类统计弹窗。
限制与注意:字段名区分大小写;函数式内容需在 outFields 中声明所用字段;Arcade 表达式在 fieldInfos 中需使用 expression/ 前缀;函数内容必须有返回值;GeoJSON 字段需使用 properties/ 前缀。具体收费、平台或效果未提供。