2020-01-08 22:42:43 +08:00
|
|
|
import { Scene, PointLayer, Popup } from '@antv/l7';
|
2019-11-27 14:54:53 +08:00
|
|
|
import { GaodeMap } from '@antv/l7-maps';
|
2019-11-26 17:51:29 +08:00
|
|
|
|
2019-11-14 11:50:12 +08:00
|
|
|
const scene = new Scene({
|
|
|
|
id: 'map',
|
2019-11-27 14:54:53 +08:00
|
|
|
map: new GaodeMap({
|
2019-11-26 17:51:29 +08:00
|
|
|
pitch: 48.62562,
|
|
|
|
style: 'light',
|
|
|
|
center: [ 104.026043, 31.847 ],
|
|
|
|
rotation: -0.76,
|
|
|
|
zoom: 4.48
|
2019-11-26 19:17:39 +08:00
|
|
|
})
|
2019-11-14 11:50:12 +08:00
|
|
|
});
|
2019-11-26 17:51:29 +08:00
|
|
|
|
2019-11-14 11:50:12 +08:00
|
|
|
fetch('https://gw.alipayobjects.com/os/rmsportal/oVTMqfzuuRFKiDwhPSFL.json')
|
2019-11-20 17:26:24 +08:00
|
|
|
.then(res => res.json())
|
|
|
|
.then(data => {
|
|
|
|
const pointLayer = new PointLayer({})
|
|
|
|
.source(data.list, {
|
|
|
|
parser: {
|
|
|
|
type: 'json',
|
|
|
|
x: 'j',
|
|
|
|
y: 'w'
|
|
|
|
}
|
2019-11-14 11:50:12 +08:00
|
|
|
})
|
2019-11-20 17:26:24 +08:00
|
|
|
.shape('cylinder')
|
|
|
|
.size('t', function(level) {
|
|
|
|
return [ 1, 2, level * 2 + 20 ];
|
|
|
|
})
|
2020-01-07 21:15:23 +08:00
|
|
|
.active(true)
|
2019-11-20 17:26:24 +08:00
|
|
|
.color('#006CFF')
|
|
|
|
.style({
|
|
|
|
opacity: 1.0
|
|
|
|
});
|
2020-01-08 22:42:43 +08:00
|
|
|
pointLayer.on('mousemove', e => {
|
|
|
|
const popup = new Popup({
|
|
|
|
offsets: [ 0, 0 ],
|
|
|
|
closeButton: false
|
|
|
|
})
|
|
|
|
.setLnglat(e.lngLat)
|
|
|
|
.setHTML(`<span>${e.feature.s}: ${e.feature.t}℃</span>`);
|
|
|
|
scene.addPopup(popup);
|
|
|
|
});
|
2019-11-19 10:21:43 +08:00
|
|
|
scene.addLayer(pointLayer);
|
2019-11-20 17:26:24 +08:00
|
|
|
});
|