antv-l7/examples/gallery/basic/demo/light.js

60 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-11-21 17:52:18 +08:00
import { Scene, HeatmapLayer } from '@antv/l7';
import { Mapbox } from '@antv/l7-maps';
2019-11-18 16:13:15 +08:00
const scene = new Scene({
id: 'map',
map: new Mapbox({
style: 'dark',
pitch: 43,
center: [ 120.13383079335335, 29.651873105004427 ],
2019-11-26 19:17:39 +08:00
zoom: 7.068989519212174
})
2019-11-18 16:13:15 +08:00
});
fetch(
2019-11-20 17:26:24 +08:00
'https://gw.alipayobjects.com/os/basement_prod/a1a8158d-6fe3-424b-8e50-694ccf61c4d7.csv'
2019-11-18 16:13:15 +08:00
)
2019-11-20 17:26:24 +08:00
.then(res => res.text())
.then(data => {
2019-11-19 19:03:17 +08:00
const layer = new HeatmapLayer({})
2019-11-18 16:13:15 +08:00
.source(data, {
2019-11-20 17:26:24 +08:00
parser: {
type: 'csv',
x: 'lng',
y: 'lat'
2019-11-18 16:13:15 +08:00
},
transforms: [
{
type: 'hexagon',
size: 2500,
field: 'v',
2019-11-20 17:26:24 +08:00
method: 'sum'
}
]
2019-11-18 16:13:15 +08:00
})
2019-11-20 17:26:24 +08:00
.size('sum', sum => {
2019-11-18 16:13:15 +08:00
return sum * 200;
})
2019-11-19 19:03:17 +08:00
.shape('hexagonColumn')
2019-11-18 16:13:15 +08:00
.style({
coverage: 0.8,
angle: 0,
2019-11-20 17:26:24 +08:00
opacity: 1.0
2019-11-18 16:13:15 +08:00
})
2019-11-20 17:26:24 +08:00
.color('sum', [
'#094D4A',
'#146968',
'#1D7F7E',
'#289899',
'#34B6B7',
'#4AC5AF',
'#5FD3A6',
'#7BE39E',
'#A1EDB8',
'#C3F9CC',
'#DEFAC0',
'#ECFFB1'
]);
2019-11-18 16:13:15 +08:00
scene.addLayer(layer);
});