2019-11-21 13:06:13 +08:00
|
|
|
|
---
|
|
|
|
|
title: 快速上手
|
|
|
|
|
order: 0
|
|
|
|
|
redirect_from:
|
|
|
|
|
- /zh/docs/tutorial
|
|
|
|
|
---
|
2020-11-16 15:19:41 +08:00
|
|
|
|
`markdown:docs/common/style.md`
|
2019-11-28 13:37:42 +08:00
|
|
|
|
# L7
|
2019-11-21 23:27:01 +08:00
|
|
|
|
|
2020-01-06 18:02:02 +08:00
|
|
|
|
Current version: ![L7 2.0版本号](https://badgen.net/npm/v/@antv/l7)
|
2019-11-21 13:06:13 +08:00
|
|
|
|
|
2019-11-28 13:37:42 +08:00
|
|
|
|
## 使用方法
|
2019-11-21 13:06:13 +08:00
|
|
|
|
|
2019-11-28 13:37:42 +08:00
|
|
|
|
### 通过 L7 CDN 使用
|
|
|
|
|
|
|
|
|
|
Include the L7 JS JavaScript <head> of your HTML file.
|
2019-11-21 13:06:13 +08:00
|
|
|
|
|
2020-01-30 23:43:27 +08:00
|
|
|
|
⚠️ 如果需要引用第三方地图API,请确保在先引入第三方API,然后引入L7
|
2019-12-10 20:11:26 +08:00
|
|
|
|
|
2019-11-21 13:06:13 +08:00
|
|
|
|
```html
|
|
|
|
|
<head>
|
2020-01-31 11:41:49 +08:00
|
|
|
|
<! --引入最新版的L7-->
|
|
|
|
|
<script src = 'https://unpkg.com/@antv/l7'></script>
|
|
|
|
|
|
|
|
|
|
<! --指定版本号引入L7-->
|
|
|
|
|
<script src = 'https://unpkg.com/@antv/l7@2.0.11'></script>
|
|
|
|
|
|
2019-11-21 13:06:13 +08:00
|
|
|
|
</head>
|
|
|
|
|
```
|
|
|
|
|
|
2019-11-28 23:38:18 +08:00
|
|
|
|
- [use Gaode Map](./map/amap)
|
2019-11-21 13:06:13 +08:00
|
|
|
|
|
2019-11-28 23:38:18 +08:00
|
|
|
|
- [use Mapbox Map ](./map/mapbox)
|
2019-11-21 13:06:13 +08:00
|
|
|
|
|
|
|
|
|
|
2019-11-28 13:37:42 +08:00
|
|
|
|
## 通过 Module bundle 使用
|
2019-11-21 13:06:13 +08:00
|
|
|
|
|
2019-11-28 13:37:42 +08:00
|
|
|
|
Install the npm package.
|
2019-11-21 13:06:13 +08:00
|
|
|
|
|
2019-11-28 13:37:42 +08:00
|
|
|
|
```bash
|
2019-11-21 13:06:13 +08:00
|
|
|
|
|
2019-11-28 17:49:04 +08:00
|
|
|
|
// L7 依赖
|
2020-01-07 21:15:23 +08:00
|
|
|
|
npm install --save @antv/l7
|
2019-11-21 13:06:13 +08:00
|
|
|
|
|
2019-11-28 17:49:04 +08:00
|
|
|
|
// 第三方底图依赖
|
|
|
|
|
npm install --save @antv/l7-maps;
|
2019-11-21 13:06:13 +08:00
|
|
|
|
|
|
|
|
|
```
|
2019-11-28 17:49:04 +08:00
|
|
|
|
|
2019-12-10 20:11:26 +08:00
|
|
|
|
|
2019-11-28 17:49:04 +08:00
|
|
|
|
### 初始化地图
|
|
|
|
|
|
2019-11-28 23:38:18 +08:00
|
|
|
|
#### 使用 高德 底图
|
2019-11-28 17:49:04 +08:00
|
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
|
|
|
|
|
|
import { Scene, PointLayer } from '@antv/l7';
|
|
|
|
|
import { GaodeMap } from '@antv/l7-maps';
|
|
|
|
|
|
|
|
|
|
const scene = new Scene({
|
|
|
|
|
id: 'map',
|
|
|
|
|
map: new GaodeMap({
|
|
|
|
|
pitch: 35.210526315789465,
|
2021-02-20 22:01:00 +08:00
|
|
|
|
mapStyle: 'dark',
|
2019-11-28 17:49:04 +08:00
|
|
|
|
center: [ 104.288144, 31.239692 ],
|
|
|
|
|
zoom: 4.4
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### 使用Mapbox 底图
|
|
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
|
|
|
|
|
|
import { Scene, HeatmapLayer } from '@antv/l7';
|
|
|
|
|
import { Mapbox } from '@antv/l7-maps';
|
|
|
|
|
|
|
|
|
|
const scene = new Scene({
|
|
|
|
|
id: 'map',
|
|
|
|
|
map: new Mapbox({
|
|
|
|
|
style: 'dark',
|
|
|
|
|
pitch: 0,
|
|
|
|
|
center: [ 127.5671666579043, 7.445038892195569 ],
|
|
|
|
|
zoom: 2.632456779444394
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
```
|
2020-01-06 18:02:02 +08:00
|
|
|
|
## 不同项目使用模板
|
|
|
|
|
|
|
|
|
|
不同项目模板在CodeSandbox你可以预览,也可以下载到本地
|
|
|
|
|
|
|
|
|
|
### React
|
|
|
|
|
|
|
|
|
|
[地址](https://codesandbox.io/s/l720react-jfwyz)
|
|
|
|
|
|
|
|
|
|
### Vue
|
|
|
|
|
|
|
|
|
|
[地址](https://codesandbox.io/s/l720vue-uef1x)
|
|
|
|
|
|
|
|
|
|
### Angular
|
|
|
|
|
|
|
|
|
|
[地址](https://codesandbox.io/s/angulartest-chpff)
|
|
|
|
|
|
|
|
|
|
### HTML CDN
|
|
|
|
|
[地址](https://codesandbox.io/s/l7cdndemo-gfg9m)
|