2019-11-25 15:27:56 +08:00
|
|
|
import { ImageLayer, Scene } from '@antv/l7';
|
2019-11-26 17:51:29 +08:00
|
|
|
import { Mapbox } from '@antv/l7-maps';
|
2019-10-30 11:52:36 +08:00
|
|
|
import * as React from 'react';
|
|
|
|
|
|
|
|
export default class ImageLayerDemo extends React.Component {
|
|
|
|
private scene: Scene;
|
|
|
|
|
|
|
|
public componentWillUnmount() {
|
|
|
|
this.scene.destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
public componentDidMount() {
|
|
|
|
const scene = new Scene({
|
|
|
|
id: 'map',
|
2019-11-26 17:51:29 +08:00
|
|
|
map: new Mapbox({
|
|
|
|
center: [121.268, 30.3628],
|
|
|
|
pitch: 0,
|
2020-01-02 20:14:25 +08:00
|
|
|
style: 'dark',
|
2019-11-26 17:51:29 +08:00
|
|
|
zoom: 10,
|
|
|
|
}),
|
2019-10-30 11:52:36 +08:00
|
|
|
});
|
|
|
|
const layer = new ImageLayer({});
|
|
|
|
layer.source(
|
|
|
|
'https://gw.alipayobjects.com/zos/rmsportal/FnHFeFklTzKDdUESRNDv.jpg',
|
|
|
|
{
|
|
|
|
parser: {
|
|
|
|
type: 'image',
|
|
|
|
extent: [121.168, 30.2828, 121.384, 30.4219],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
scene.addLayer(layer);
|
2019-11-01 15:36:20 +08:00
|
|
|
this.scene = scene;
|
2019-10-30 11:52:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public render() {
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
id="map"
|
|
|
|
style={{
|
|
|
|
position: 'absolute',
|
|
|
|
top: 0,
|
|
|
|
left: 0,
|
|
|
|
right: 0,
|
|
|
|
bottom: 0,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|