2019-11-25 15:27:56 +08:00
|
|
|
import { PointLayer, Scene } from '@antv/l7';
|
2019-12-17 11:14:31 +08:00
|
|
|
import { GaodeMap, Mapbox } from '@antv/l7-maps';
|
2019-11-21 13:44:32 +08:00
|
|
|
import * as React from 'react';
|
|
|
|
export default class PointImage extends React.Component {
|
2019-11-25 15:27:56 +08:00
|
|
|
// @ts-ignore
|
2019-11-21 13:44:32 +08:00
|
|
|
private scene: Scene;
|
|
|
|
|
|
|
|
public componentWillUnmount() {
|
|
|
|
this.scene.destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
public async componentDidMount() {
|
|
|
|
const response = await fetch(
|
|
|
|
'https://gw.alipayobjects.com/os/basement_prod/893d1d5f-11d9-45f3-8322-ee9140d288ae.json',
|
|
|
|
);
|
|
|
|
const scene = new Scene({
|
|
|
|
id: 'map',
|
2021-01-14 17:28:13 +08:00
|
|
|
map: new Mapbox({
|
2019-11-26 17:51:29 +08:00
|
|
|
center: [121.4, 31.258134],
|
2021-01-14 17:28:13 +08:00
|
|
|
zoom: 12,
|
2019-11-26 17:51:29 +08:00
|
|
|
pitch: 0,
|
2020-12-15 01:24:46 +08:00
|
|
|
style: 'normal',
|
2019-11-26 17:51:29 +08:00
|
|
|
}),
|
2019-11-21 13:44:32 +08:00
|
|
|
});
|
2019-12-17 11:14:31 +08:00
|
|
|
this.scene = scene;
|
2019-11-21 13:44:32 +08:00
|
|
|
scene.addImage(
|
|
|
|
'00',
|
2020-12-15 01:24:46 +08:00
|
|
|
'https://gw.alipayobjects.com/mdn/rms_fcd5b3/afts/img/A*g8cUQ7pPT9YAAAAAAAAAAAAAARQnAQ',
|
2019-11-21 13:44:32 +08:00
|
|
|
);
|
|
|
|
scene.addImage(
|
|
|
|
'01',
|
2020-12-15 01:24:46 +08:00
|
|
|
'https://gw.alipayobjects.com/mdn/rms_fcd5b3/afts/img/A*LTcXTLBM7kYAAAAAAAAAAAAAARQnAQ',
|
2019-11-21 13:44:32 +08:00
|
|
|
);
|
|
|
|
scene.addImage(
|
|
|
|
'02',
|
2020-12-15 01:24:46 +08:00
|
|
|
'https://gw.alipayobjects.com/mdn/rms_fcd5b3/afts/img/A*g8cUQ7pPT9YAAAAAAAAAAAAAARQnAQ',
|
2019-11-21 13:44:32 +08:00
|
|
|
);
|
2020-05-15 21:07:04 +08:00
|
|
|
const i = 0;
|
2020-02-17 22:47:33 +08:00
|
|
|
const data = await response.json();
|
2020-05-15 21:07:04 +08:00
|
|
|
const newData = data.map((item: any) => {
|
|
|
|
item.type = '00';
|
|
|
|
return item;
|
|
|
|
});
|
2020-12-15 01:24:46 +08:00
|
|
|
const imageLayer = new PointLayer({
|
|
|
|
blend: 'normal',
|
|
|
|
})
|
2020-05-15 21:07:04 +08:00
|
|
|
.source(newData, {
|
|
|
|
parser: {
|
|
|
|
type: 'json',
|
|
|
|
x: 'longitude',
|
|
|
|
y: 'latitude',
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.shape('type', (v: any) => {
|
|
|
|
return v;
|
|
|
|
})
|
|
|
|
// .shape('triangle')
|
|
|
|
// .color('red')
|
2020-12-15 01:24:46 +08:00
|
|
|
.active(false)
|
|
|
|
.size(20);
|
2020-05-15 21:07:04 +08:00
|
|
|
scene.addLayer(imageLayer);
|
2021-01-14 17:28:13 +08:00
|
|
|
imageLayer.on('mousedown', (e) => {
|
|
|
|
console.log('mousedown', e);
|
|
|
|
});
|
|
|
|
imageLayer.on('click', (e) => {
|
|
|
|
console.log('click', e);
|
|
|
|
});
|
2019-11-21 13:44:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public render() {
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
id="map"
|
|
|
|
style={{
|
|
|
|
position: 'absolute',
|
|
|
|
top: 0,
|
|
|
|
left: 0,
|
|
|
|
right: 0,
|
|
|
|
bottom: 0,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|