antv-l7/examples/line/path/demo/bus_dark.js

48 lines
1010 B
JavaScript
Raw Normal View History

2019-11-21 17:52:18 +08:00
import { Scene, LineLayer } from '@antv/l7';
import { Mapbox } from '@antv/l7-maps';
2019-11-16 22:22:13 +08:00
const scene = new Scene({
id: 'map',
map: new Mapbox({
center: [ 103.83735, 1.3602538 ],
pitch: 4.00000000000001,
zoom: 10.210275860702593,
rotation: 19.313180925794313,
2019-11-26 19:17:39 +08:00
style: 'dark'
})
2019-11-16 22:22:13 +08:00
});
2019-11-20 17:26:24 +08:00
fetch(
'https://gw.alipayobjects.com/os/basement_prod/ee07641d-5490-4768-9826-25862e8019e1.json'
)
.then(res => res.json())
.then(data => {
const layer = new LineLayer({})
.source(data, {
parser: {
type: 'json',
coordinates: 'path'
}
2019-11-16 22:22:13 +08:00
})
2019-11-20 17:26:24 +08:00
.size('level', level => {
return [ 0.8, level * 1 ];
})
.shape('line')
.color(
'level',
[
'#312B60',
'#4A457E',
'#615C99',
'#816CAD',
'#A67FB5',
'#C997C7',
'#DEB8D4',
'#F5D4E6',
'#FAE4F1',
'#FFF3FC'
].slice(0, 8)
);
2019-11-16 22:22:13 +08:00
scene.addLayer(layer);
});