Skip to content

Commit 3cf7a11

Browse files
author
zhaoqin
committed
fix: 优化maplibre skills
AI-GEN: 100% hy4 flash - 之前一般L7被挂载到window上,优化和example用法一样 - 移除多余的l7-arc3d.md
1 parent 05e3401 commit 3cf7a11

9 files changed

Lines changed: 29 additions & 45 deletions

File tree

‎skills/maplibregl/SKILL.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ v6(默认):
6868
* [查询 REST Data 并加载 FGB](./prompts/few-shot-examples/rest-data-fgb.md)
6969
* [加载 WMTS 栅格瓦片](./prompts/few-shot-examples/load-wmts.md)
7070
* [加载 WMS 栅格图层](./prompts/few-shot-examples/load-wms.md)
71-
* [L7 3D 弧线/飞线](./prompts/few-shot-examples/l7-arc3d.md)
71+
* [L7 3D 弧线/飞线](./modules/mapping/l7-layer.md)
7272

7373
v5(用户明确要求时):
7474

@@ -110,7 +110,7 @@ v5(用户明确要求时):
110110
**L7 可视化(L7Layer)的可选依赖**:iClient 两种产物都不内置 L7。凡是 L7 场景(`L7Layer`、3D 弧线 `arc3d`/飞线/大圆弧 `greatcircle`、L7 热力图、3D 柱图等,见 [l7-layer.md](modules/mapping/l7-layer.md)),必须按版本额外加载 maplibregl-l7-render(地址是 param-defaults.json `cdns.*.l7Render`):
111111

112112
- v5:顺序固定为 **maplibre-gl-enhance 5.9.0-2**(L7 场景核心固定用 enhance,不用普通 5.6.0)→ `maplibregl-l7-render/0.0.4/maplibregl-l7-render.js` 普通 script(注册全局 `L7`)→ iClient script。
113-
- v6(12.2.0 起的 iClient mjs):iClient mjs **不静态 import** render——`./L7/l7-render` 是懒读 `window.L7` 的 var external Proxy。三步:① import map 把 `maplibre-gl` 映到 **enhance 6.14.0 mjs**(替换核心映射),并加 `maplibregl-l7-render` → `1.0.0/maplibregl-l7-render.mjs`;② 业务单个 module 内加 `import * as L7Render from 'maplibregl-l7-render'; window.L7 = L7Render;`;③ 照常具名导入 `L7Layer`。不使用 L7 的页面零配置(只映核心、不请求 render)。1.0.0 mjs CDN 待发布,未就位时注明可换自托管同目录 mjs,不降级 v5。
113+
- v6(12.2.0 起的 iClient mjs):iClient 导出 `setL7Render(renderModule)` 用于显式注入 render 命名空间,**不再使用 `window.L7` 全局/懒 Proxy**。三步:① import map 把 `maplibre-gl` 映到 **enhance 6.14.0 mjs**(替换核心映射),加 `maplibregl-l7-render` → `1.0.0/maplibregl-l7-render.mjs`,独立页面可再加 `iclient-maplibregl` → iClient mjs 以支持裸名导入;② 业务单个 module 内 `import * as L7 from 'maplibregl-l7-render'; import { setL7Render, L7Layer } from 'iclient-maplibregl'; setL7Render(L7);`;③ 在 `map.on('load')` 内 `new L7Layer(...)` 并 `map.addLayer(layer)`。不使用 L7 的页面零配置(只映核心、不请求 render)。1.0.0 mjs CDN 待发布,未就位时注明可换自托管同目录 mjs,不降级 v5。
114114
- **L7 场景无条件用 enhance**(v5/v6 都是):fork 版 render 每帧调 `map.getCRS()`,普通核心没有该方法,运行时报 `getCRS is not a function`、场景出不了图;与底图是否 3857 无关,是 enhance 三分法的固定例外(仓库 67 个 l7 示例均为 `include="L7,maplibre-gl-enhance"`)。
115115

116116
不要混用 MapboxGL 资源包、`mapboxgl` 命名空间或 Mapbox 专属 API。仅当已核实的功能确实需要时才加载 enhance 资源(**原生 EPSG:4326 显示(`CRS.EPSG4326`)或 3857/4326 之外的自定义投影**;4326 服务接受动态投影到 3857 出图时不需要;**使用 `L7Layer` 时无条件需要**,与坐标系无关)。v5 用 enhance 5.9.0-2 普通脚本;**v6 默认仍生成 v6**:import map 把裸名 `maplibre-gl` 映到 enhance 6.14.0 mjs(核心超集 fork,含 CRS),不因此降级 v5(写法见 [coordinate-system.md](rules/coordinate-system.md))。不要让用户使用 `dist/maplibregl/include-maplibregl.js`,该脚本仅用于官方示例页。
@@ -131,7 +131,7 @@ v5(用户明确要求时):
131131

132132
* 默认提供独立 HTML、默认按 v6 生成;仅在用户要求时提供代码片段或 v5。
133133
* **默认 v6 输出前自检(任一不满足即为错误)**:不出现 `iclient-maplibregl-es6.min.js`/`iclient-maplibregl.js` 普通 script(组合③桥接除外);有 `<script type="importmap">` 且在 module 脚本之前;业务代码无 `maplibregl.supermap.` 前缀、业务类全部在 mjs 的 `import { ... }` 列表中;核心为 `import * as maplibregl`。
134-
* 含 `L7Layer` 的页面:v5 script 顺序固定为 enhance 5.9.0-2(不是普通核心)→ `maplibregl-l7-render/0.0.4/maplibregl-l7-render.js` → iClient;v6 import map 必须把 `maplibre-gl` 映到 enhance 6.14.0 mjs 且含裸名 `maplibregl-l7-render` → 1.0.0 render mjs,业务单个 module 内含 `import * as L7Render ...; window.L7 = L7Render` 桥接与 `L7Layer` 具名导入。两版都禁止用 `include-maplibregl.js` 的 `include="L7"`。
134+
* 含 `L7Layer` 的页面:v5 script 顺序固定为 enhance 5.9.0-2(不是普通核心)→ `maplibregl-l7-render/0.0.4/maplibregl-l7-render.js` → iClient;v6 import map 必须把 `maplibre-gl` 映到 enhance 6.14.0 mjs 且含裸名 `maplibregl-l7-render` → 1.0.0 render mjs,业务单个 module 内必须 `import * as L7 from 'maplibregl-l7-render'; import { setL7Render, L7Layer } from 'iclient-maplibregl'; setL7Render(L7);`(禁止 `window.L7 = ...`)。两版都禁止用 `include-maplibregl.js` 的 `include="L7"`。
135135
* HTML 中引用的脚本、样式表、样式和 DOM 元素都必须存在;v6 页面与 iClient 内部裸名指向同一核心 URL(单例)。
136136
* 使用正确的导入方式:v6 核心 `import * as`、iClient 具名导入;v5 使用 `maplibregl` 全局与 `maplibregl.supermap.*`。
137137
* 安全时使用具体默认值;用户专属的 URL、数据集名称和凭据必须明确标出。
68 KB
Binary file not shown.
4 KB
Binary file not shown.

‎skills/maplibregl/modules/mapping/l7-layer.md‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,27 @@ iClient 的 `L7Layer` 是 @antv/L7 图层与 MapLibre 地图之间的桥接:
1313

1414
iClient 产物(v5 的 js 与 v6 的 mjs)**不打包 L7 渲染库**。地址/版本以 [param-defaults.json](../../rules/param-defaults.json) 的 `cdns` 段为准,禁止使用仅供官方示例页的 `include-maplibregl.js`。
1515

16-
**v6(默认)——L7 页面核心固定映到 enhance,import map 两条映射 + 业务 module 两行桥接:**
16+
**v6(默认)——L7 页面核心固定映到 enhance,import map 三条映射 + 业务 module 用 `setL7Render` 注入:**
1717

1818
```html
1919
<link rel="stylesheet" href="https://iclient.supermap.io/web/libs/maplibre-gl-js-enhance/6.14.0/maplibre-gl-enhance.css">
2020
<script type="importmap">
2121
{ "imports": {
2222
"maplibre-gl": "https://iclient.supermap.io/web/libs/maplibre-gl-js-enhance/6.14.0/maplibre-gl-enhance.mjs",
23-
"maplibregl-l7-render": "https://iclient.supermap.io/web/libs/maplibregl-l7-render/1.0.0/maplibregl-l7-render.mjs"
23+
"maplibregl-l7-render": "https://iclient.supermap.io/web/libs/maplibregl-l7-render/1.0.0/maplibregl-l7-render.mjs",
24+
"iclient-maplibregl": "https://iclient.supermap.io/dist/maplibregl/iclient-maplibregl.mjs"
2425
} }
2526
</script>
2627
<script type="module">
2728
import * as maplibregl from 'maplibre-gl';
28-
import * as L7Render from 'maplibregl-l7-render';
29-
import { L7Layer } from 'https://iclient.supermap.io/dist/maplibregl/iclient-maplibregl.mjs';
30-
window.L7 = L7Render; // iClient mjs 以懒读 window.L7 的 Proxy 取 render,真正 new L7Layer 时才穿透读取
29+
import * as L7 from 'maplibregl-l7-render';
30+
import { setL7Render, L7Layer } from 'iclient-maplibregl';
31+
setL7Render(L7); // iClient 官方注入 API;必须在 new L7Layer 之前调用
3132
</script>
3233
```
3334

3435
- **L7 场景无条件使用 enhance,与底图坐标系无关**:fork 版 render 每帧经 `map.getCRS()` 取坐标系参数,普通 maplibre-gl 核心没有该方法(运行时 `getCRS is not a function`,L7 场景出不了图);enhance 是核心超集 fork,直接把 `maplibre-gl` 映到 enhance 6.14.0 mjs 即可。这是 [coordinate-system.md](../../rules/coordinate-system.md) enhance 三分法之外的固定例外。仓库 67 个 l7 示例也一律 `include="L7,maplibre-gl-enhance"`(提交 adb7137a7)。
35-
- iClient mjs(12.2.0 起构建)**不静态 import render**:`./L7/l7-render` 是一个懒读 `globalThis.L7` 的 var external Proxy,求值阶段不读全局,`new L7Layer` 时才穿透。因此 import map 的 `maplibregl-l7-render` 映射服务于**业务 module 自己的 import**,且必须在业务代码前完成 `window.L7 = L7Render` 桥接(import 提升先于语句求值,赋值在 map load 回调之前完成,时序可靠);不挂 window 会报 `L7.LineLayer is not a constructor`。
36+
- iClient mjs(12.2.0 起构建)导出 `setL7Render(renderModule)`:业务 module 把 `import * as L7 from 'maplibregl-l7-render'` 得到的命名空间显式传给 iClient,之后 `new L7Layer` 才能拿到 L7 的 `LineLayer` 等构造器;**不再需要也不应使用 `window.L7` 全局**。import map 的 `maplibregl-l7-render` 映射服务于业务 module 自己的裸名 import;未调用 `setL7Render(L7)` 会报 `L7.LineLayer is not a constructor`。
3637
- render mjs 内部同样裸名 `import 'maplibre-gl'`,与页面、iClient 经同一 import map 拿到**同一个含 CRS 的 enhance 模块实例**。
3738
- 不用 L7 的页面不加 render 映射、不下载 render,基础导入不受影响;import map 缺 render 映射时,业务 module 的裸名 import 会在页面加载阶段报 `Failed to resolve module specifier "maplibregl-l7-render"`。
3839
- render 1.x ESM 会把只读的 maplibre-gl 模块命名空间挂到 `window.maplibregl`,iClient 已用 `Object.isExtensible` 守卫跳过向只读对象挂 `supermap`(`src/maplibregl/namespace.js`),无需页面处理。
@@ -122,9 +123,9 @@ map.addLayer(layer);
122123

123124
## 4. 关键要点与易错点
124125

125-
- **两版 L7 页面都固定用 enhance 核心**(与底图是否 3857 无关,render 每帧调 `map.getCRS()`):v6 import map 把 `maplibre-gl` 映到 enhance 6.14.0 mjs 并加 `maplibregl-l7-render` 映射,业务 module 加 `import * as L7Render ...; window.L7 = L7Render` 两行桥接;v5 固定 enhance 5.9.0-2 → render 0.0.4 → iClient 三个普通 script 顺序。
126+
- **两版 L7 页面都固定用 enhance 核心**(与底图是否 3857 无关,render 每帧调 `map.getCRS()`):v6 import map 把 `maplibre-gl` 映到 enhance 6.14.0 mjs 并加 `maplibregl-l7-render` 映射,业务 module 用 `setL7Render(L7)` 注入 render(禁止 `window.L7 = ...`);v5 固定 enhance 5.9.0-2 → render 0.0.4 → iClient 三个普通 script 顺序。
126127
- `source()` 数据必须在 `map.addLayer(layer)` 前配好;运行期换数据用 `layer.getL7Layer().setData(...)`,改配置后 `layer.reRender()`。
127128
- OD 数据用 parser 的 `x/y/x1/y1` 字段映射,不要传 LineString 坐标数组。
128129
- 3D 弧线要设置 `pitch`(建议 50~60)并缩放到合适层级,否则弧顶看不出高度。
129130
- 一个地图只创建一个 L7 scene(首个 L7Layer `onAdd` 时自动创建并挂在 `map.$l7scene`);多个 L7 图层各自 `new L7Layer` 后分别 `map.addLayer` 即可。
130-
- v6 报 `Failed to resolve module specifier "maplibregl-l7-render"`:业务 module import 了 render 但 import map 缺该裸名(见 [error-handling.md](../../rules/error-handling.md) 第 7 节);报 `L7.LineLayer is not a constructor`:缺 `window.L7 = L7Render` 桥接;报 `map.getCRS is not a function`:核心映成了普通核心,需改映 enhance。v5 报 `L7.LineLayer is not a constructor`:render 0.0.4 script 缺失或顺序不对。
131+
- v6 报 `Failed to resolve module specifier "maplibregl-l7-render"`:业务 module import 了 render 但 import map 缺该裸名(见 [error-handling.md](../../rules/error-handling.md) 第 7 节);报 `L7.LineLayer is not a constructor`:未调用 `setL7Render(L7)` 或注入对象不是 render 命名空间;报 `map.getCRS is not a function`:核心映成了普通核心,需改映 enhance。v5 报 `L7.LineLayer is not a constructor`:render 0.0.4 script 缺失或顺序不对。

‎skills/maplibregl/prompts/few-shot-examples/l7-arc3d.md‎

Lines changed: 0 additions & 18 deletions
This file was deleted.

‎skills/maplibregl/prompts/system-prompt.md‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,25 +77,26 @@
7777
**可选依赖 maplibregl-l7-render(仅 L7 场景)**:iClient 两种产物都不内置 L7;凡使用 `L7Layer`(3D 弧线 `arc3d`/飞线/`greatcircle`、L7 热力图等),必须按版本提供(地址只取 param-defaults.json 的 `cdns.*.l7Render`,详见 `modules/mapping/l7-layer.md`)。**L7 页面核心固定用 enhance**——fork 版 render 每帧调 `map.getCRS()`,普通核心无此方法(运行时报 `getCRS is not a function`,场景不出图),与底图坐标系无关:
7878

7979
- v5:三个普通 script 顺序固定——maplibre-gl-**enhance** 5.9.0-2 → `https://iclient.supermap.io/web/libs/maplibregl-l7-render/0.0.4/maplibregl-l7-render.js` → iClient(运行时读全局 `L7`)。
80-
- v6(12.2.0 起的 iClient mjs):iClient mjs **不静态 import** render,`./L7/l7-render` 是懒读 `window.L7` 的 var external Proxy;import map 两条映射(核心映到 **enhance 6.14.0 mjs**,不是普通核心),业务仍是**单个** module,加两行桥接后再具名导入:
80+
- v6(12.2.0 起的 iClient mjs):iClient 导出 `setL7Render(renderModule)` 用于显式注入 L7 render 命名空间,**不再使用 `window.L7` 全局/懒 Proxy**;import map 三条映射(核心映到 **enhance 6.14.0 mjs**,不是普通核心),业务仍是**单个** module:
8181

8282
```html
8383
<link rel="stylesheet" href="https://iclient.supermap.io/web/libs/maplibre-gl-js-enhance/6.14.0/maplibre-gl-enhance.css">
8484
<script type="importmap">
8585
{ "imports": {
8686
"maplibre-gl": "https://iclient.supermap.io/web/libs/maplibre-gl-js-enhance/6.14.0/maplibre-gl-enhance.mjs",
87-
"maplibregl-l7-render": "https://iclient.supermap.io/web/libs/maplibregl-l7-render/1.0.0/maplibregl-l7-render.mjs"
87+
"maplibregl-l7-render": "https://iclient.supermap.io/web/libs/maplibregl-l7-render/1.0.0/maplibregl-l7-render.mjs",
88+
"iclient-maplibregl": "https://iclient.supermap.io/dist/maplibregl/iclient-maplibregl.mjs"
8889
} }
8990
</script>
9091
<script type="module">
91-
import * as L7Render from 'maplibregl-l7-render';
92-
import { L7Layer } from 'https://iclient.supermap.io/dist/maplibregl/iclient-maplibregl.mjs';
93-
window.L7 = L7Render; // iClient mjs 的 render 是懒读 window.L7 的 Proxy,new L7Layer 时才穿透
92+
import * as L7 from 'maplibregl-l7-render';
93+
import { setL7Render, L7Layer } from 'iclient-maplibregl';
94+
setL7Render(L7); // 必须在 new L7Layer 之前;npm 项目同样用裸名 iclient-maplibregl
9495
// 业务代码……
9596
</script>
9697
```
9798

98-
不使用 L7 的页面零配置:import map 只映核心、不请求 render。缺 render 映射时报 `Failed to resolve module specifier "maplibregl-l7-render"`;缺 `window.L7` 桥接报 `L7.LineLayer is not a constructor`;核心没映 enhance 报 `map.getCRS is not a function`。1.0.0 mjs CDN 待发布;生成时若仍 404,回复中注明可换自托管同目录 mjs,不因此降级 v5。
99+
不使用 L7 的页面零配置:import map 只映核心、不请求 render。缺 render 映射时报 `Failed to resolve module specifier "maplibregl-l7-render"`;未调用 `setL7Render(L7)` 报 `L7.LineLayer is not a constructor`;核心没映 enhance 报 `map.getCRS is not a function`。1.0.0 mjs CDN 待发布;生成时若仍 404,回复中注明可换自托管同目录 mjs,不因此降级 v5。
99100

100101
## 关键规则
101102

0 commit comments

Comments
 (0)