This commit is contained in:
2912401452 2021-12-08 15:41:08 +08:00
commit 5ad8f45a50
3 changed files with 27 additions and 18 deletions

View File

@ -17,6 +17,7 @@ export default class ReglTexture2D implements ITexture2D {
private texture: regl.Texture2D; private texture: regl.Texture2D;
private width: number; private width: number;
private height: number; private height: number;
private isDistroy: boolean = false;
constructor(reGl: regl.Regl, options: ITexture2DInitializationOptions) { constructor(reGl: regl.Regl, options: ITexture2DInitializationOptions) {
const { const {
@ -89,6 +90,9 @@ export default class ReglTexture2D implements ITexture2D {
} }
public destroy() { public destroy() {
this.texture.destroy(); if (!this.isDistroy) {
this.texture.destroy();
}
this.isDistroy = true;
} }
} }

View File

@ -17,7 +17,7 @@ export default class GaodeMapComponent extends React.Component {
map: new GaodeMap({ map: new GaodeMap({
center: [121.107846, 30.267069], center: [121.107846, 30.267069],
pitch: 0, pitch: 0,
// style: 'normal', style: 'dark',
zoom: 20, zoom: 20,
animateEnable: false, animateEnable: false,
}), }),
@ -28,7 +28,7 @@ export default class GaodeMapComponent extends React.Component {
// min = 'min', // min = 'min',
// max = 'max', // max = 'max',
// none = 'none', // none = 'none',
const layer = new PointLayer({ zIndex: 2 }) const layer = new PointLayer({ zIndex: 2, blend: 'additive' })
.source( .source(
[ [
{ {
@ -50,17 +50,16 @@ export default class GaodeMapComponent extends React.Component {
) )
.shape('circle') .shape('circle')
// .shape('normal') // .shape('normal')
.color('blue') .color('#1990FF')
.size(10) .size(20)
.style({ .style({
stroke: '#fff', stroke: '#fff',
storkeWidth: 2, storkeWidth: 2,
// offsets: [100, 100],
}); });
this.scene = scene; this.scene = scene;
const linelayer = new LineLayer({}) const linelayer = new LineLayer({ blend: 'additive' })
.source({ .source({
type: 'FeatureCollection', type: 'FeatureCollection',
features: [ features: [
@ -80,14 +79,17 @@ export default class GaodeMapComponent extends React.Component {
], ],
}) })
.shape('line') .shape('line')
.color('#0ff') .color('#78FFFF')
.size(10); .size(10);
scene.on('loaded', () => { scene.on('loaded', () => {
scene.addLayer(linelayer); // scene.addLayer(linelayer);
scene.addLayer(layer); scene.addLayer(layer);
}); });
layer.on('click', () => console.log('point click')); layer.on('click', () => console.log('point click'));
layer.on('mousemove', (e) => {
console.log(e.feature);
});
linelayer.on('click', () => console.log('line click')); linelayer.on('click', () => console.log('line click'));
} }

View File

@ -1,7 +1,7 @@
import { Scene, PolygonLayer, PointLayer, Map } from '@antv/l7-mini'; import { Scene, PolygonLayer, PointLayer, Map } from '@antv/l7-mini';
// import { Scene } from '@antv/l7'; // import { Scene } from '@antv/l7';
// import { PolygonLayer, PointLayer } from '@antv/l7-layers'; // import { PolygonLayer, PointLayer } from '@antv/l7-layers';
import { GaodeMap } from '@antv/l7-maps'; import { GaodeMap, Mapbox } from '@antv/l7-maps';
import * as React from 'react'; import * as React from 'react';
export default class ScaleComponent extends React.Component { export default class ScaleComponent extends React.Component {
@ -9,7 +9,6 @@ export default class ScaleComponent extends React.Component {
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
map: new GaodeMap({ map: new GaodeMap({
hash: true,
center: [105, 32], center: [105, 32],
pitch: 0, pitch: 0,
zoom: 3, zoom: 3,
@ -42,12 +41,6 @@ export default class ScaleComponent extends React.Component {
dir: 'in', // in - out dir: 'in', // in - out
}, },
}); });
scene.addLayer(layer);
scene.fitBounds([
[48.073279, 3.067261],
[160.573279, 54.003394],
]);
const layer2 = new PolygonLayer({ blend: 'normal' }) const layer2 = new PolygonLayer({ blend: 'normal' })
.source(data) .source(data)
@ -65,7 +58,17 @@ export default class ScaleComponent extends React.Component {
.style({ .style({
opacity: 1.0, opacity: 1.0,
}); });
scene.addLayer(layer2);
scene.on('loaded', () => {
scene.addLayer(layer);
scene.addLayer(layer2);
scene.fitBounds([
[48.073279, 3.067261],
[160.573279, 54.003394],
]);
console.log('getBounds', scene.getBounds());
});
}); });
} }