antvis/L7 · antv-l7 · SKILL.md
蚂蚁可视化引擎
基于WebGL的地理空间数据可视化库,提供高性能地图渲染与交互能力。
这是公开 Agent Skill 的中文说明,由采集翻译或编辑润色,完整内容以上游 SKILL.md 为准。适用于 Cursor / Claude Code / Codex / Gemini。 打开上游 SKILL.md
安装
通用(npx skills)
npx skills add antvis/L7 -s antv-l7
Cursor
把该 Skill 复制到项目的 .cursor/skills/antv-l7/ 目录
Claude Code
npx skills add antvis/L7 -a claude-code -s antv-l7
中文说明
# AntV L7 地理空间可视化
AntV L7 是基于 WebGL 的大规模地理空间数据可视化引擎,支持多种地图底图和丰富的可视化图层类型。
## ⚠️ 重要约束
**作用域声明:以下约束仅适用于 WeaveFox(本仓库)环境。**
**在 WeaveFox 环境下,高德地图配置禁止传入 token 参数。**
在 WeaveFox 项目中,L7 已配置默认 token。在该环境下,`GaodeMap` 配置中**不要**设置 `token` 字段,否则会导致地图加载失败。
```javascript
// ✅ 正确 - 不传 token
new GaodeMap({
center: [120.19, 30.26],
zoom: 10,
style: 'light',
});
// ❌ 错误 - 禁止传入 token
new GaodeMap({
center: [120.19, 30.26],
zoom: 10,
style: 'light',
token: 'xxx', // 不要这样做!
});
```
## 选型指南
### 简单点位展示(< 100 个点)
**优先使用 Marker**,而非 PointLayer:
```javascript
import { Marker, Popup } from '@antv/l7';
let currentPopup = null;
// ✅ 推荐 - 少量点位使用 Marker
data.forEach((point) => {
const marker = new Marker({
color: '#5B8FF9',
draggable: false,
}).setLnglat([point.lng, point.lat]);
marker.on('click', () => {
// 统一单实例 popup:先移除旧 popup,再创建新 popup
if (currentPopup) scene.removePopup(currentPopup);
currentPopup = new Popup({
anchor: 'bottom',
className: 'outing-popup',
lngLat: { lng: point.lng, lat: point.lat },
html: `<div>${point.name}</div>`,
});
scene.addPopup(currentPopup);
});
// 必须使用 scene.addMarker,否则地图缩放/平移时 Marker 不会更新位置
scene.addMarker(marker);
});
```
**Marker vs PointLayer 对比:**
| 特性 | Marker | PointLayer |
| -------- | ------------------- | ----------------------- |
| 适用场景 | < 100 个点位 | > 100 个点位/大规模数据 |
| 性能 | DOM 渲染,轻量 | WebGL 渲染,高性能 |
| 交互 | 原生 DOM 事件,灵活 | 需绑定图层事件 |
| 自定义 | 支持任意 HTML/CSS | 受限于 L7 样式配置 |
| Popup | 内置支持 | 需额外配置 |
### 大规模数据可视化(> 100 个点)
使用 PointLayer 进行 WebGL 渲染:
```javascript
import { PointLayer } from '@antv/l7';
// ✅ 推荐 - 大量点位使用 PointLayer
const pointLayer = new PointLayer()
.source(data, {
parser: { type: 'json', x: 'lng', y: 'lat' },
})
.shape('circle')
.size(10)
.color('#5B8FF9');
scene.addLayer(pointLayer);
```
## React 最佳实践
### 核心原则
1. **单次初始化**:地图场景只初