2019-11-19 19:03:17 +08:00
|
|
|
import { HeatmapLayer } from '@l7/layers';
|
2019-11-14 11:50:12 +08:00
|
|
|
import { Scene } from '@l7/scene';
|
|
|
|
const scene = new Scene({
|
|
|
|
id: 'map',
|
|
|
|
style: 'light',
|
2019-11-16 22:22:13 +08:00
|
|
|
pitch: 47.49999999999995,
|
|
|
|
center: [114.05737552216226, 22.542656745583486],
|
|
|
|
zoom: 12.405122702055305,
|
2019-11-14 11:50:12 +08:00
|
|
|
type: 'mapbox',
|
|
|
|
});
|
2019-11-16 22:22:13 +08:00
|
|
|
window.mapScene = scene;
|
2019-11-14 11:50:12 +08:00
|
|
|
fetch(
|
|
|
|
'https://gw.alipayobjects.com/os/basement_prod/513add53-dcb2-4295-8860-9e7aa5236699.json',
|
|
|
|
)
|
|
|
|
.then((res) => res.json())
|
|
|
|
.then((data) => {
|
2019-11-19 19:03:17 +08:00
|
|
|
const layer = new HeatmapLayer({})
|
2019-11-14 11:50:12 +08:00
|
|
|
.source(data, {
|
|
|
|
transforms: [
|
|
|
|
{
|
|
|
|
type: 'hexagon',
|
2019-11-16 22:22:13 +08:00
|
|
|
size: 100,
|
2019-11-14 11:50:12 +08:00
|
|
|
field: 'h12',
|
|
|
|
method: 'sum',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
})
|
|
|
|
.size('sum', [0, 600])
|
2019-11-19 19:03:17 +08:00
|
|
|
.shape('hexagonColumn')
|
2019-11-14 11:50:12 +08:00
|
|
|
.style({
|
|
|
|
coverage: 0.8,
|
|
|
|
angle: 0,
|
|
|
|
opacity: 1.0,
|
|
|
|
})
|
|
|
|
.color(
|
|
|
|
'sum',
|
|
|
|
[
|
2019-11-16 22:22:13 +08:00
|
|
|
'#094D4A', '#146968',
|
|
|
|
'#1D7F7E', '#289899',
|
|
|
|
'#34B6B7', '#4AC5AF',
|
|
|
|
'#5FD3A6', '#7BE39E',
|
|
|
|
'#A1EDB8', '#CEF8D6'
|
|
|
|
].reverse()
|
2019-11-14 11:50:12 +08:00
|
|
|
);
|
|
|
|
scene.addLayer(layer);
|
|
|
|
});
|