antv-l7/examples/heatmap/hexagon/demo/world.js

58 lines
1.1 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-17 17:31:01 +08:00
const scene = new Scene({
id: 'map',
map: new GaodeMap({
style: 'light',
pitch: 0,
center: [ 104.995156, 31.450658 ],
2019-11-26 19:17:39 +08:00
zoom: 3.79
})
2019-11-17 17:31:01 +08:00
});
2019-11-20 17:26:24 +08:00
fetch(
'https://gw.alipayobjects.com/os/basement_prod/337ddbb7-aa3f-4679-ab60-d64359241955.json'
)
.then(res => res.json())
.then(data => {
const layer = new HeatmapLayer({})
2019-11-17 17:31:01 +08:00
.source(data, {
transforms: [
{
type: 'hexagon',
size: 90000,
field: 'capacity',
2019-11-20 17:26:24 +08:00
method: 'sum'
}
]
2019-11-17 17:31:01 +08:00
})
2019-11-20 17:26:24 +08:00
.size('sum', value => {
2019-11-17 17:31:01 +08:00
return value * 50;
})
.shape('hexagon')
.style({
coverage: 0.9,
angle: 0,
2019-11-20 17:26:24 +08:00
opacity: 1.0
2019-11-17 17:31:01 +08:00
})
2019-11-20 17:26:24 +08:00
.color(
'sum',
[
'#3F4BBA',
'#3F4BBA',
'#3F4BBA',
'#3F4BBA',
'#3C73DA',
'#3C73DA',
'#3C73DA',
'#0F62FF',
'#0F62FF',
'#30B2E9',
'#30B2E9',
'#40C4CE'
].reverse()
);
2019-11-17 17:31:01 +08:00
scene.addLayer(layer);
});