arcgis-js-component
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "arcgis-js-component":https://skillpi.com/zh/skills/deepskill-682420bd5388c625cb3b7365aa37d222b93e99baf6545932abc0d0afc6d99de4。安装前核对上游来源和版本:https://skillhub.cn/skills/user_d03b9e2c/arcgis-js-component。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
skillhub.cn
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
ArcGIS Maps SDK for JavaScript 5.0 的 Web 组件开发辅助,用于在基于组件的方法下创建或迁移到 arcgis-scene、arcgis-map、arcgis-sketch 及其他自定义元素。常见触发词包括:“component”、“arcgis-scene”、“arcgis-sketch”、“arcgis-map”、“map-components”、“web component”、“custom element”、“migrate to component”、“5.0 component”、“Sketch widget deprecated”、“replace widget with component”、“declarative map”。除非另有说明,否则使用 ArcGIS JS SDK 5.0 CDN。
介绍来源: third_party · user_d03b9e2c · 1.0.3 参考来源
SkillPi 解读
- 能完成的任务
- ArcGIS Maps SDK for JavaScript 从 5.0 版本开始大力推进组件化(Web Components), 将原来的命令式 API(`new SceneView()`, `new Sketch()` 等)迁移到声明式的自定义元素 (`<arcgis-scene>`, `<arcgis-sketch>` 等)。此技能提供组件化开发的完整指南。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: arcgis-js-component
description: >
ArcGIS Maps SDK for JavaScript 5.0 Components (Web Components) 开发辅助。
This skill should be used when the user wants to create or migrate to the component-based
approach using arcgis-scene, arcgis-map, arcgis-sketch, and other custom elements.
Triggers: "component", "arcgis-scene", "arcgis-sketch", "arcgis-map", "map-components",
"web component", "custom element", "migrate to component", "5.0 component",
"Sketch widget deprecated", "replace widget with component", "declarative map".
Unless otherwise specified, use ArcGIS JS SDK 5.0 CDN.ArcGIS JS Components 开发技能
概述
ArcGIS Maps SDK for JavaScript 从 5.0 版本开始大力推进组件化(Web Components),
将原来的命令式 API(new SceneView(), new Sketch() 等)迁移到声明式的自定义元素
(<arcgis-scene>, <arcgis-sketch> 等)。此技能提供组件化开发的完整指南。
触发条件
使用本技能当用户请求涉及:
- 创建使用 arcgis-scene / arcgis-map 组件的应用
- 使用 arcgis-sketch 替代已弃用的 Sketch widget
- 使用 map-components 下的组件替换之前的 widget 组件
- 将现有命令式代码迁移到组件化方式
- 在 5.0 CDN 下进行组件开发
- 组件间通信、属性设置、事件监听等问题
核心原则
- 使用 5.0 CDN —
https://js.arcgis.com/5.0/,4.x 本地 CDN 不支持组件自定义元素 - 声明式视图 —
<arcgis-scene camera-position="...">替代new SceneView({...}) - referenceElement 优先 — 组件间通过
referenceElement关联,而非直接传递view对象 - 时序关键 — 组件属性设置和就绪等待有严格顺序要求
- 坐标系一致 — GraphicsLayer 的 spatialReference 须与 arcgis-scene camera 坐标系一致
项目结构模板
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
<title>Title</title>
<link rel="stylesheet" href="https://js.arcgis.com/5.0/esri/themes/light/main.css"/>
<style>
html, body { padding: 0; margin: 0; height: 100%; width: 100%; }
arcgis-scene { height: 100%; width: 100%; }
</style>
</head>
<body>
<arcgis-scene id="viewDiv"
camera-position="121.0076, 23.3814, 9000"
camera-tilt="35"
camera-heading="0">
<arcgis-sketch id="sketchEl" slot="top-right"></arcgis-sketch>
</arcgis-scene>
<!-- 5.0 运行时:注册所有自定义元素 -->
<script type="module" src="https://js.arcgis.com/5.0/"></script>
<script type="module">
// ─── 加载 ArcGIS JS API 模块 ───
const [
Map, SpatialReference,
ElevationLayer, GraphicsLayer
] = await $arcgis.import([
"@arcgis/core/Map.js",
"@arcgis/core/geometry/SpatialReference.js",
"@arcgis/core/layers/ElevationLayer.js",
"@arcgis/core/layers/GraphicsLayer.js",
]);
// ─── 天地图底图 ───
const getTianditu = await $arcgis.import(
"https://openlayers.vip/examples/resources/tianditu_layers_local_es6.js"
);
const tiandituLayers = getTianditu.default({ type: "img_w" }); // img_w=影像, vec_w=矢量, cva_w=注记
// ─── 创建 Map(含高程地形)───
const map = new Map({
basemap: { baseLayers: [tiandituLayers.base, tiandituLayers.anno] },
ground: {
layers: [
new ElevationLayer({
url: 'https://www.geosceneonline.cn/image/rest/services/OpenData/ChinaTerrain3D/ImageServer'
})
]
}
});
// ─── arcgis-scene 组件获取 view ───
const viewElement = document.querySelector("arcgis-scene");
const view = viewElement.view;
view.map = map;
// ─── arcgis-sketch 配置(所有属性必须在 viewOnReady 前设置)───
const sketchEl = document.getElementById("sketchEl");
const sketchLayer = new GraphicsLayer({
elevationInfo: { mode: "on-the-ground" },
spatialReference: SpatialReference.WGS84
});
map.add(sketchLayer);
sketchEl.referenceElement = "viewDiv";
sketchEl.defaultGraphicsLayerDisabled = true;
sketchEl.creationMode = "single";
sketchEl.layer = sketchLayer;
await viewElement.viewOnReady();
// view.map 赋值会重置相机,显式定位
view.goTo({
position: { x: 121.0076, y: 23.3814, z: 9000, spatialReference: SpatialReference.WGS84 },
heading: 0,
tilt: 35
});
await sketchEl.componentOnReady();
console.log("组件初始化完成");
</script>
</body>
</html>
底图初始化
天地图底图
通过 tianditu_layers_local_eqQOW30ICo3.js 加载天地图瓦片服务:
const getTianditu = await $arcgis.import(
"https://openlayers.vip/examples/resources/tianditu_layers_local_es6.js"
);
const layers = getTianditu.default({ type: "img_w" });
type 参数选项:
| 值 | 类型 | 说明 |
|---|---|---|
"img_w" |
影像底图 | 卫星影像(推荐 3D 场景使用) |
"vec_w" |
矢量底图 | 矢量地图 |
"cva_w" |
注记图层 | 中文注记叠加 |
返回对象包含 .base(底图图层)和 .anno(注记图层),组合传入 basemap.baseLayers。
3D 高程地形
SceneView 3D 场景需要地面高程数据:
ground: {
layers: [
new ElevationLayer({
url: 'https://www.geosceneonline.cn/image/rest/services/OpenData/ChinaTerrain3D/ImageServer'
})
]
}
核心组件速查
arcgis-scene / arcgis-map
<arcgis-scene id="viewDiv" camera-position="lon, lat, alt" camera-tilt="45" camera-heading="0">
viewElement.view获取 view 对象viewElement.viewOnReady()等待就绪- 支持子组件通过
slot属性自动定位
arcgis-sketch(替代已弃用 Sketch widget)
详细文档见 references/arcgis-sketch.md。
关键要点:
defaultGraphicsLayerDisabled = true必须设置event.detail即CreateEvent,detail.state/detail.toolEventInfo与旧版兼容- 3D SceneView 下 GraphicsLayer 需
elevationInfo: { mode: "on-the-ground" }
其他常用组件
| 组件 | 用途 |
|---|---|
<arcgis-zoom> |
缩放控件 |
<arcgis-compass> |
指南针 |
<arcgis-home> |
回到初始视角 |
<arcgis-search> |
搜索控件 |
<arcgis-layer-list> |
图层列表 |
<arcgis-legend> |
图例 |
<arcgis-basemap-toggle> |
底图切换 |
<arcgis-expand> |
可展开面板容器 |
初始化时序规则
详细说明见 references/timing.md。
核心规则:
设置组件属性 → viewOnReady() → view.goTo() 定位 → componentOnReady()
必须记住:所有 arcgis-sketch 的属性(layer, referenceElement, defaultGraphicsLayerDisabled, creationMode)必须在 viewElement.viewOnReady() 之前设置。
严格按照官方示例和API,严禁使用不存在的类和工具。
常见错误与解决
| 错误 | 原因 | 解决 |
|---|---|---|
Cannot set properties of undefined (setting 'map') |
4.x CDN 不支持自定义元素 | 改用 5.0 CDN |
Failed to create layerview for layer 'Sketch Layer' |
组件自建图层坐标系冲突 | defaultGraphicsLayerDisabled=true + 自建 GraphicsLayer |
| arcgis-sketch 事件不触发 | componentOnReady 在 viewOnReady 前 |
调整等待顺序 |
| 交叉多边形检测不生效 | event.detail.state / toolEventInfo 未使用 |
参考 references/arcgis-sketch.md |
| 相机不定位到目标 | view.map=map 重置相机 |
viewOnReady 后调用 view.goTo() |
官方资源
-
组件 API 参考: https://developers.arcgis.com/javascript/latest/references/map-components/**,比如 arcgis-sketch 组件的 API 地址为:https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-sketch/
-
组件入门教程: https://developers.arcgis.com/javascript/latest/tutorials/create-a-web-app-using-components/
-
arcgis-sketch 参考: https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-sketch/
当前收录版本
1.0.3
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供 ArcGIS JS SDK 5.0 组件化迁移的完整解决方案
- 覆盖从命令式 API 到声明式组件的实际开发痛点
- 包含天地图底图、3D 高程地形等本土化实用配置
亮点
- 触发词精准覆盖组件化开发核心场景(arcgis-scene, arcgis-sketch, migrate to component 等)
- 边界清晰,有效区分传统 widget 开发模式
待提升项
-
文档结构优化 原报告严重程度:轻微
文档内容完整但篇幅较长(约600行),建议拆分或增加目录导航;缺少显式的 When to Use 使用场景说明章节
改进建议:可考虑将详细 API 说明移至独立参考文件;在主文档开头增加 When to Use 段落明确适用场景
亮点
- 提供完整的项目结构模板和端到端 HTML 示例
- frontmatter 元数据完整规范
亮点
- 工具来源明确(5.0 CDN、天地图脚本、高程服务 URL 均有效)
- 覆盖主要异常场景并提供解决方案(坐标系冲突、初始化时序、CDN 版本问题)
- 参数使用符合官方 API 规范
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。
文档引用的域名或地址
这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。
- developers.arcgis.com
- js.arcgis.com
- openlayers.vip
- www.geosceneonline.cn
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。