antv-l7/examples/polygon/fill/demo/polygon.js

48 lines
915 B
JavaScript
Raw Normal View History

2019-11-21 17:52:18 +08:00
import { Scene, PolygonLayer, LineLayer } from '@antv/l7';
import { AMap } from '@antv/l7-maps';
const scene = new Scene({
id: 'map',
map: new AMap({
pitch: 0,
style: 'light',
center: [ 107.042225, 37.66565 ],
zoom: 3.87
2019-11-26 19:17:39 +08:00
})
});
2019-11-10 21:20:26 +08:00
fetch('https://gw.alipayobjects.com/os/rmsportal/JToMOWvicvJOISZFCkEI.json')
2019-11-20 17:26:24 +08:00
.then(res => res.json())
.then(data => {
const colors = [
'#D7F9F0',
'#A6E1E0',
'#72BED6',
'#5B8FF9',
'#3474DB',
'#005CBE',
'#00419F',
'#00287E'
];
const layer = new PolygonLayer({})
.source(data)
2019-11-20 17:26:24 +08:00
.color('name', colors)
.shape('fill')
.style({
2019-11-10 21:20:26 +08:00
opacity: 0.9
2019-11-16 22:22:13 +08:00
});
2019-11-20 17:26:24 +08:00
const layer2 = new LineLayer({
zIndex: 2
})
2019-11-16 22:22:13 +08:00
.source(data)
2019-11-20 17:26:24 +08:00
.color('#fff')
.size(0.3)
.style({
2019-11-16 22:22:13 +08:00
opacity: 1
2019-11-20 17:26:24 +08:00
});
scene.addLayer(layer);
2019-11-16 22:22:13 +08:00
scene.addLayer(layer2);
});