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

53 lines
1.0 KiB
JavaScript
Raw Normal View History

2019-11-21 17:52:18 +08:00
import { Scene, PolygonLayer, LineLayer } from '@antv/l7';
import { GaodeMap } from '@antv/l7-maps';
2019-11-14 11:50:12 +08:00
const scene = new Scene({
id: 'map',
map: new GaodeMap({
pitch: 0,
style: 'light',
center: [ 116.368652, 39.93866 ],
zoom: 10.07
2019-11-26 19:17:39 +08:00
})
2019-11-14 11:50:12 +08:00
});
2019-11-20 17:26:24 +08:00
fetch(
'https://gw.alipayobjects.com/os/basement_prod/1d27c363-af3a-469e-ab5b-7a7e1ce4f311.json'
)
.then(res => res.json())
.then(data => {
const layer = new PolygonLayer({})
2019-11-14 11:50:12 +08:00
.source(data)
2019-11-20 17:26:24 +08:00
.color(
'unit_price',
[
'#1A4397',
'#2555B7',
'#3165D1',
'#467BE8',
'#6296FE',
'#7EA6F9',
'#98B7F7',
'#BDD0F8',
'#DDE6F7',
'#F2F5FC'
].reverse()
)
.shape('fill')
.style({
2019-11-14 11:50:12 +08:00
opacity: 1
2019-11-20 17:26:24 +08:00
});
const layer2 = new LineLayer({
zIndex: 2
})
2019-11-15 15:43:59 +08:00
.source(data)
2019-11-20 17:26:24 +08:00
.color('#fff')
2020-01-06 18:02:02 +08:00
.size(0.8)
2019-11-20 17:26:24 +08:00
.style({
2019-11-15 15:43:59 +08:00
opacity: 1
2019-11-20 17:26:24 +08:00
});
2019-11-14 11:50:12 +08:00
scene.addLayer(layer);
2019-11-15 15:43:59 +08:00
scene.addLayer(layer2);
2019-11-14 11:50:12 +08:00
});