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-20 17:26:24 +08:00
|
|
|
pitch: 56.499,
|
|
|
|
center: [ 114.07737552216226, 22.542656745583486 ],
|
|
|
|
rotation: 39.19,
|
|
|
|
zoom: 12.47985,
|
|
|
|
type: 'mapbox'
|
2019-11-14 11:50:12 +08:00
|
|
|
});
|
2019-11-16 22:22:13 +08:00
|
|
|
window.mapScene = scene;
|
2019-11-14 11:50:12 +08:00
|
|
|
fetch(
|
2019-11-20 17:26:24 +08:00
|
|
|
'https://gw.alipayobjects.com/os/basement_prod/513add53-dcb2-4295-8860-9e7aa5236699.json'
|
2019-11-14 11:50:12 +08:00
|
|
|
)
|
2019-11-20 17:26:24 +08:00
|
|
|
.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',
|
2019-11-20 17:26:24 +08:00
|
|
|
method: 'sum'
|
|
|
|
}
|
|
|
|
]
|
2019-11-14 11:50:12 +08:00
|
|
|
})
|
2019-11-20 17:26:24 +08:00
|
|
|
.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,
|
2019-11-20 17:26:24 +08:00
|
|
|
opacity: 1.0
|
2019-11-14 11:50:12 +08:00
|
|
|
})
|
|
|
|
.color(
|
|
|
|
'sum',
|
|
|
|
[
|
2019-11-20 17:26:24 +08:00
|
|
|
'#094D4A',
|
|
|
|
'#146968',
|
|
|
|
'#1D7F7E',
|
|
|
|
'#289899',
|
|
|
|
'#34B6B7',
|
|
|
|
'#4AC5AF',
|
|
|
|
'#5FD3A6',
|
|
|
|
'#7BE39E',
|
|
|
|
'#A1EDB8',
|
|
|
|
'#CEF8D6'
|
|
|
|
].reverse()
|
2019-11-14 11:50:12 +08:00
|
|
|
);
|
|
|
|
scene.addLayer(layer);
|
|
|
|
});
|