antv-l7/demos/tutorial/control/demo/amap.js

59 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-11-06 11:57:42 +08:00
import { Scene } from '@l7/scene';
2019-11-10 21:20:26 +08:00
import { PointLayer } from '@l7/layers'
import { Scale, Zoom, Layers } from '@l7/component';
2019-11-06 11:57:42 +08:00
const scene = new Scene({
id: 'map',
pitch: 0,
type: 'amap',
style: 'dark',
center: [121.40, 31.258134],
2019-11-16 22:22:13 +08:00
zoom: 14,
2019-11-06 11:57:42 +08:00
});
2019-11-10 21:20:26 +08:00
fetch('https://gw.alipayobjects.com/os/basement_prod/893d1d5f-11d9-45f3-8322-ee9140d288ae.json')
.then((res) => res.json())
.then((data) => {
const pointLayer =
new PointLayer({
})
.source(data, {
parser: {
type: 'json',
x: 'longitude',
y: 'latitude'
}
}).shape('circle')
.size('unit_price', [5, 25])
.color('name',['#49B5AD', "#5B8FF9"])
.style({
opacity: 0.3,
strokeWidth: 1,
})
scene.addLayer(pointLayer);
var overlayers = {
"围栏填充": pointLayer,
};
var baseLayers = {
"基础地图": pointLayer,
};
const layersControl = new Layers({
overlayers: overlayers,
});
scene.addControl(layersControl);
});
const zoomControl = new Zoom();
2019-11-16 22:22:13 +08:00
const scaleControl = new Scale({
position:"bottomright"
});
2019-11-10 21:20:26 +08:00
scene.addControl(zoomControl);
scene.addControl(scaleControl);