2019-11-27 14:54:53 +08:00
|
|
|
import { PointLayer, Scale, Scene, Layers, Zoom } from '@antv/l7';
|
2019-11-28 00:26:09 +08:00
|
|
|
import { GaodeMap } from '@antv/l7-maps';
|
2019-11-27 14:54:53 +08:00
|
|
|
const scene = new Scene({
|
|
|
|
id: 'map',
|
2019-11-28 00:26:09 +08:00
|
|
|
map: new GaodeMap({
|
|
|
|
style: 'light',
|
|
|
|
pitch: 0,
|
|
|
|
center: [ 121.4316962, 31.26082325 ],
|
|
|
|
zoom: 15.056
|
|
|
|
})
|
2019-11-27 14:54:53 +08:00
|
|
|
});
|
2019-12-02 15:16:45 +08:00
|
|
|
fetch(
|
2019-12-02 17:27:39 +08:00
|
|
|
'https://gw.alipayobjects.com/os/basement_prod/893d1d5f-11d9-45f3-8322-ee9140d288ae.json'
|
2019-12-02 15:16:45 +08:00
|
|
|
)
|
2019-11-27 14:54:53 +08:00
|
|
|
.then(res => res.json())
|
|
|
|
.then(data => {
|
2019-12-02 15:16:45 +08:00
|
|
|
const pointLayer = new PointLayer({})
|
|
|
|
.source(data, {
|
|
|
|
parser: {
|
|
|
|
type: 'json',
|
|
|
|
x: 'longitude',
|
2019-12-02 17:27:39 +08:00
|
|
|
y: 'latitude'
|
|
|
|
}
|
2019-11-27 14:54:53 +08:00
|
|
|
})
|
2019-12-02 15:16:45 +08:00
|
|
|
.shape('circle')
|
2019-12-02 17:27:39 +08:00
|
|
|
.size('unit_price', [ 5, 25 ])
|
|
|
|
.color('name', [ '#49B5AD', '#5B8FF9' ])
|
2019-12-02 15:16:45 +08:00
|
|
|
.style({
|
|
|
|
opacity: 0.3,
|
2019-12-02 17:27:39 +08:00
|
|
|
strokeWidth: 1
|
2019-12-02 15:16:45 +08:00
|
|
|
});
|
2019-11-27 14:54:53 +08:00
|
|
|
|
|
|
|
scene.addLayer(pointLayer);
|
|
|
|
const overlayers = {
|
2020-01-14 17:01:29 +08:00
|
|
|
气泡图: pointLayer
|
2019-11-27 14:54:53 +08:00
|
|
|
};
|
|
|
|
const layersControl = new Layers({
|
|
|
|
overlayers
|
|
|
|
});
|
|
|
|
|
|
|
|
scene.addControl(layersControl);
|
|
|
|
});
|
|
|
|
|
2019-11-28 10:36:15 +08:00
|
|
|
const zoomControl = new Zoom({
|
|
|
|
position: 'topright'
|
|
|
|
});
|
2019-11-27 14:54:53 +08:00
|
|
|
const scaleControl = new Scale({
|
|
|
|
position: 'bottomright'
|
|
|
|
});
|
|
|
|
scene.addControl(zoomControl);
|
|
|
|
scene.addControl(scaleControl);
|