antv-l7/examples/line/arc/demo/arc.js

42 lines
943 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-10 21:20:26 +08:00
const scene = new Scene({
id: 'map',
map: new Mapbox({
pitch: 0,
style: 'dark',
center: [ 0, 23.107329 ],
2019-11-26 19:17:39 +08:00
zoom: 0
})
2019-11-10 21:20:26 +08:00
});
2019-11-20 17:26:24 +08:00
fetch(
'https://gw.alipayobjects.com/os/basement_prod/b83699f9-a96d-49b8-b2ea-f99299faebaf.json'
)
.then(res => res.json())
.then(data => {
2019-11-10 21:20:26 +08:00
function getAirportCoord(idx) {
2019-11-20 17:26:24 +08:00
return [ data.airports[idx][3], data.airports[idx][4] ];
2019-11-10 21:20:26 +08:00
}
2019-11-20 17:26:24 +08:00
const routes = data.routes.map(function(airline) {
2019-11-10 21:20:26 +08:00
return {
2019-11-20 17:26:24 +08:00
coord: [ getAirportCoord(airline[1]), getAirportCoord(airline[2]) ]
};
2019-11-10 21:20:26 +08:00
});
2019-11-20 17:26:24 +08:00
const layer = new LineLayer({})
.source(routes, {
parser: {
type: 'json',
coordinates: 'coord'
}
})
.size(0.6)
.shape('arc')
.color('rgb(5, 5, 50)')
.style({
opacity: 0.05
});
2019-11-10 21:20:26 +08:00
scene.addLayer(layer);
2019-11-20 17:26:24 +08:00
});