antv-l7/examples/heatmap/grid/demo/heatmap3.js

62 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-11-21 17:52:18 +08:00
import { Scene, HeatmapLayer } from '@antv/l7';
import { GaodeMap } from '@antv/l7-maps';
2019-11-18 16:13:15 +08:00
const scene = new Scene({
id: 'map',
map: new GaodeMap({
style: 'light',
pitch: 0,
center: [ 110.097892, 33.853662 ],
2019-11-26 19:17:39 +08:00
zoom: 4.056
})
2019-11-18 16:13:15 +08:00
});
fetch(
2019-11-20 17:26:24 +08:00
'https://gw.alipayobjects.com/os/basement_prod/7359a5e9-3c5e-453f-b207-bc892fb23b84.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-19 19:03:17 +08:00
parser: {
type: 'csv',
x: 'lng',
y: 'lat'
},
transforms: [
{
type: 'grid',
size: 20000,
field: 'v',
method: 'sum'
}
]
})
2019-11-20 17:26:24 +08:00
.size('count', value => {
2019-11-19 19:03:17 +08:00
return value * 0;
})
.shape('circle')
.style({
coverage: 0.9,
2019-11-20 17:26:24 +08:00
angle: 0
2019-11-19 19:03:17 +08:00
})
2019-11-20 17:26:24 +08:00
.color(
'count',
[
'#8C1EB2',
'#8C1EB2',
'#DA05AA',
'#F0051A',
'#FF2A3C',
'#FF4818',
'#FF4818',
'#FF8B18',
'#F77B00',
'#ED9909',
'#ECC357',
'#EDE59C'
].reverse()
);
2019-11-18 16:13:15 +08:00
scene.addLayer(layer);
});