Skip to content

antvis/L7 / skills/l7

antv-l7

Verified

Comprehensive guide for AntV L7 geospatial visualization library. Use when users need to: (1) Create interactive maps with WebGL rendering (2) Visualize geographic data (points, lines, polygons, heatmaps) (3) Build location-based data dashboards (4) Add map layers, interactions, or animations (5) Process and display GeoJSON, CSV, or other spatial data (6) Integrate maps with AMap (GaodeMap), Mapbox, Maplibre, or standalone L7 Map (7) Optimize performance for large-scale geographic datasets

FileKindSize
COMPLETENESS_REPORT.mdmarkdown10.4 KB
README.mdmarkdown6.5 KB
SKILL.mdskill md6.8 KB
index.mdmarkdown4.4 KB
metadata/skill-dependency.jsonconfig3.2 KB
metadata/skill-tags.jsonconfig2.5 KB
metadata/version-compatibility.jsonconfig1.5 KB
references/animation/layer-animation.mdmarkdown6.4 KB
references/core/map-types.mdmarkdown13.8 KB
references/core/scene-lifecycle.mdmarkdown9.6 KB
references/core/scene-methods.mdmarkdown15.9 KB
references/core/scene.mdmarkdown10.2 KB
references/data/source-csv.mdmarkdown10.7 KB
references/data/source-geojson.mdmarkdown9.6 KB
references/data/source-json.mdmarkdown12.6 KB
references/data/source-mvt.mdmarkdown13.3 KB
references/data/source-parser.mdmarkdown12.0 KB
references/data/source-raster.mdmarkdown20.8 KB
references/interaction/components.mdmarkdown3.8 KB
references/interaction/controls.mdmarkdown15.6 KB
references/interaction/events.mdmarkdown9.8 KB
references/interaction/layer-popup.mdmarkdown17.3 KB
references/interaction/marker-layer.mdmarkdown19.7 KB
references/interaction/popup.mdmarkdown9.2 KB
references/layers/base-layer.mdmarkdown14.1 KB
references/layers/heatmap.mdmarkdown10.0 KB
references/layers/image.mdmarkdown12.2 KB
references/layers/line.mdmarkdown10.0 KB
references/layers/point.mdmarkdown10.8 KB
references/layers/polygon.mdmarkdown9.4 KB
references/layers/raster.mdmarkdown13.7 KB
references/layers/tile-raster.mdmarkdown16.6 KB
references/layers/tile-vector.mdmarkdown13.4 KB
references/performance/optimization.mdmarkdown7.4 KB
references/visual/mapping.mdmarkdown12.9 KB
references/visual/style.mdmarkdown11.7 KB

references/interaction/components.md

View on GitHub
# L7 Components Reference

本文档整合了 L7 的所有交互组件使用指南。

## Popup - 信息弹窗

详见 [popup.md](popup.md) - 完整的 Popup 组件使用指南,包括基础用法、高级配置、样式定制等。

### 快速示例

```javascript
import { Popup } from '@antv/l7';

const popup = new Popup({
  closeButton: true,
})
  .setLnglat([120.19, 30.26])
  .setHTML('<h3>标题</h3><p>内容</p>');

scene.addPopup(popup);
```

### 事件绑定

```javascript
layer.on('click', (e) => {
  const popup = new Popup().setLnglat(e.lnglat).setHTML(`<div>${e.feature.properties.name}</div>`);
  scene.addPopup(popup);
});
```

## Marker - 标注点

自定义 HTML 标注,支持拖拽。

### 基础用法

```javascript
import { Marker } from '@antv/l7';

const marker = new Marker().setLnglat([120.19, 30.26]);

scene.addMarker(marker);
```

### 自定义样式

```javascript
const el = document.createElement('div');
el.className = 'custom-marker';
el.innerHTML = '<i class="icon"></i>';

const marker = new Marker({
  element: el,
}).setLnglat([120.19, 30.26]);

scene.addMarker(marker);
```

### 拖拽标注

```javascript
const marker = new Marker({
  draggable: true,
}).setLnglat([120.19, 30.26]);

marker.on('dragend', () => {
  const lnglat = marker.getLnglat();
  console.log('新位置:', lnglat);
});

scene.addMarker(marker);
```

## Controls - 地图控件

L7 提供多种内置控件。

### Zoom Control - 缩放控件

```javascript
import { Zoom } from '@antv/l7';

const zoom = new Zoom({
  position: 'topright',
});

scene.addControl(zoom);
```

### Scale Control - 比例尺

```javascript
import { Scale } from '@antv/l7';

const scale = new Scale({
  position: 'bottomleft',
});

scene.addControl(scale);
```

### Layer Control - 图层控制

```javascript
import { LayerControl } from '@antv/l7';

const layerControl = new LayerControl({
  layers: [
    { layer: pointLayer, name: '点图层' },
    { layer: lineLayer, name: '线图层' },
  ],
});

scene.addControl(layerControl);
```

## Legend - 图例

自定义图例组件。

### 基础图例

```javascript
import { Legend } from '@antv/l7';

const legend = new Legend({
  position: 'bottomright',
  items: [
    { color: '#5B8FF9', value: '类型A' },
    { color: '#5AD8A6', value: '类型B' },
    { color: '#FF6B3B', value: '类型C' },
  ],
});

scene.addControl(legend);
```

### 渐变图例

```javascript
const legend = new Legend({
  position: 'bottomright',
  type: 'gradient',
  items: [
    { color: '#FFF5B8', value: '0' },
    { color: '#FFAB5C', value: '50' },
    { color: '#FF6B3B', value: '100' },
  ],
});

scene.addControl(legend);
```

## 组件组合使用

实际应用中通常组合使用多个组件:

```javascript
import { Scene, PointLayer, Popup, Marker, Zoom, Scale } from '@antv/l7';

// 添加控件
scene.addControl(new Zoom({ position: 'topright' }));
scene.addControl(new Scale({ position: 'bottomleft' }));

// 添加标注
const marker = new Marker().setLnglat([120.19, 30.26]);
scene.addMarker(marker);

// 点击显示 Popup
layer.on('click', (e) => {
  const popup = new Popup().setLnglat(e.lnglat).setHTML(`<h3>${e.feature.properties.name}</h3>`);
  scene.addPopup(popup);
});
```

## 常见问题

### 1. Popup 位置偏移

使用 `offset` 调整位置:

```javascript
const popup = new Popup({
  offset: [0, -10], // x, y 偏移量
});
```

### 2. Marker 自定义图标

```javascript
const el = document.createElement('div');
el.style.backgroundImage = 'url(icon.png)';
el.style.width = '32px';
el.style.height = '32px';

const marker = new Marker({ element: el });
```

### 3. 控件位置

支持的位置:

- `'topleft'` - 左上角
- `'topright'` - 右上角
- `'bottomleft'` - 左下角
- `'bottomright'` - 右下角

## 相关文档

- [events.md](events.md) - 事件处理详细指南
- [popup.md](popup.md) - Popup 完整文档
deprecation-and-migrationaddyosmani/agent-skillsManages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
performance-optimizationaddyosmani/agent-skillsOptimizes application performance across frontend, backend, queries, and databases. Use when performance requirements exist, when you suspect performance regressions, when Core Web Vitals or load times need improvement, when N+1 query patterns need fixing, or when profiling reveals bottlenecks.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall
agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall