2021-10-13 16:51:20 +08:00
|
|
|
|
---
|
|
|
|
|
title: 点图层
|
|
|
|
|
order: 3
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
`markdown:docs/common/style.md`
|
|
|
|
|
|
|
|
|
|
## 简介
|
2021-10-14 10:41:51 +08:00
|
|
|
|
|
2021-10-14 10:40:11 +08:00
|
|
|
|
用户在地球模式下使用点图层无需做额外的操作,L7 会自动识别地球模式并相关的转化
|
2021-10-13 16:51:20 +08:00
|
|
|
|
|
2021-12-30 12:01:10 +08:00
|
|
|
|
## 示例图片
|
|
|
|
|
|
|
|
|
|
<img src="https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*ck1XSZ4Vw0QAAAAAAAAAAAAAARQnAQ" alt="L7 地球点图层" width="300" height="300" >
|
|
|
|
|
|
2021-10-13 16:51:20 +08:00
|
|
|
|
## 使用
|
|
|
|
|
|
|
|
|
|
```javascript
|
2021-12-30 12:01:10 +08:00
|
|
|
|
import { Scene, PointLayer, EarthLayer } from '@antv/l7';
|
|
|
|
|
import { Earth } from '@antv/l7-maps';
|
|
|
|
|
const scene = new Scene({
|
|
|
|
|
id: 'map',
|
|
|
|
|
map: new Earth({}),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const d = [{ lng: 121.61865234375, lat: 25.29437116258816 }];
|
|
|
|
|
|
2021-10-14 10:40:11 +08:00
|
|
|
|
const pointlayer = new PointLayer()
|
2021-12-30 12:01:10 +08:00
|
|
|
|
.source(d, {
|
|
|
|
|
parser: {
|
|
|
|
|
type: 'json',
|
|
|
|
|
x: 'lng',
|
|
|
|
|
y: 'lat',
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
.shape('circle')
|
|
|
|
|
.color('#f00')
|
|
|
|
|
.size(10)
|
|
|
|
|
.active(true);
|
|
|
|
|
|
|
|
|
|
const earthlayer = new EarthLayer()
|
2021-10-14 10:40:11 +08:00
|
|
|
|
.source(
|
2021-12-30 12:01:10 +08:00
|
|
|
|
'https://gw.alipayobjects.com/mdn/rms_23a451/afts/img/A*3-3NSpqRqUoAAAAAAAAAAAAAARQnAQ',
|
2021-10-14 10:40:11 +08:00
|
|
|
|
{
|
|
|
|
|
parser: {
|
2021-12-30 12:01:10 +08:00
|
|
|
|
type: 'image',
|
2021-10-14 10:40:11 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
)
|
2021-12-30 12:01:10 +08:00
|
|
|
|
.style({
|
|
|
|
|
globelOtions: {
|
|
|
|
|
ambientRatio: 1, // 环境光
|
|
|
|
|
},
|
|
|
|
|
});
|
2021-10-13 16:51:20 +08:00
|
|
|
|
|
2021-12-30 12:01:10 +08:00
|
|
|
|
scene.on('loaded', () => {
|
|
|
|
|
scene.addLayer(earthlayer);
|
|
|
|
|
scene.addLayer(pointlayer);
|
|
|
|
|
});
|
2021-10-13 16:51:20 +08:00
|
|
|
|
```
|