mirror of https://gitee.com/antv-l7/antv-l7
Merge branch 'master' of https://github.com/antvis/L7
This commit is contained in:
commit
e95b5941fe
|
@ -4,6 +4,7 @@ import { IMapConfig } from '../map/IMapService';
|
|||
import { IRenderConfig } from '../renderer/IRendererService';
|
||||
|
||||
export interface ISceneService {
|
||||
destroyed: boolean;
|
||||
on(type: string, handle: (...args: any[]) => void): void;
|
||||
off(type: string, handle: (...args: any[]) => void): void;
|
||||
removeAllListeners(event?: string): this;
|
||||
|
|
|
@ -28,6 +28,8 @@ import { ISceneService } from './ISceneService';
|
|||
*/
|
||||
@injectable()
|
||||
export default class Scene extends EventEmitter implements ISceneService {
|
||||
public destroyed: true;
|
||||
|
||||
@inject(TYPES.SceneID)
|
||||
private readonly id: string;
|
||||
/**
|
||||
|
@ -203,7 +205,7 @@ export default class Scene extends EventEmitter implements ISceneService {
|
|||
}
|
||||
|
||||
public async render() {
|
||||
if (this.rendering) {
|
||||
if (this.rendering && !this.destroyed) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -212,6 +214,9 @@ export default class Scene extends EventEmitter implements ISceneService {
|
|||
if (!this.inited) {
|
||||
// 还未初始化完成需要等待
|
||||
await this.initPromise;
|
||||
if (this.destroy) {
|
||||
this.destroy();
|
||||
}
|
||||
|
||||
// FIXME: 初始化 marker 容器,可以放到 map 初始化方法中?
|
||||
this.logger.info(' render inited');
|
||||
|
@ -249,15 +254,21 @@ export default class Scene extends EventEmitter implements ISceneService {
|
|||
}
|
||||
|
||||
public destroy() {
|
||||
if (!this.inited) {
|
||||
this.destroyed = true;
|
||||
return;
|
||||
}
|
||||
this.emit('destroy');
|
||||
this.inited = false;
|
||||
|
||||
this.layerService.destroy();
|
||||
this.rendererService.destroy();
|
||||
this.map.destroy();
|
||||
|
||||
this.interactionService.destroy();
|
||||
this.controlService.destroy();
|
||||
this.markerService.destroy();
|
||||
this.removeAllListeners();
|
||||
this.map.destroy();
|
||||
this.inited = false;
|
||||
unbind(this.$container as HTMLDivElement, this.handleWindowResized);
|
||||
window
|
||||
.matchMedia('screen and (min-resolution: 2dppx)')
|
||||
|
|
|
@ -16,7 +16,6 @@ export function createRendererContainer(
|
|||
z-index:2;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
background: inherit;
|
||||
pointer-events: none;
|
||||
`;
|
||||
$container.id = `l7-scene-${containerCounter++}`;
|
||||
|
|
|
@ -419,7 +419,7 @@ export default class AMapService
|
|||
private removeLogoControl(): void {
|
||||
// @ts-ignore
|
||||
const logo = document.getElementsByClassName('amap-logo');
|
||||
if (logo) {
|
||||
if (logo && logo[0]) {
|
||||
logo[0].setAttribute('style', 'display: none !important');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,6 @@ export default React.memo(function Chart(props: ISourceProps) {
|
|||
} else {
|
||||
layer.setData(data, sourceOption);
|
||||
}
|
||||
// 临时解决:若开启,每次更新之后自适应缩放;
|
||||
// TODO:是否可以统一到Layer的option里,目前问题是Layer的autoFit一直为true,无法触发更新
|
||||
if (sourceOption.autoFit) {
|
||||
layer.fitBounds();
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ export interface IStyleOptions {
|
|||
export interface ISourceOptions extends ISourceCFG {
|
||||
data: any;
|
||||
// 每次更新数据之后是否自适应缩放
|
||||
autoFit: boolean;
|
||||
autoFit?: boolean;
|
||||
}
|
||||
|
||||
export interface IActiveOptions {
|
||||
|
|
|
@ -22,6 +22,7 @@ export default class Column extends React.Component {
|
|||
rotation: 134.9507,
|
||||
}),
|
||||
});
|
||||
scene.destroy();
|
||||
this.scene = scene;
|
||||
fetch(
|
||||
'https://gw.alipayobjects.com/os/basement_prod/893d1d5f-11d9-45f3-8322-ee9140d288ae.json',
|
||||
|
|
|
@ -88,7 +88,7 @@ export default class World extends React.Component {
|
|||
.color('#fff')
|
||||
.style({
|
||||
opacity: 1,
|
||||
sttoke: '#FFF',
|
||||
stroke: '#FFF',
|
||||
strokeWidth: 0,
|
||||
});
|
||||
scene.addLayer(pointLayer);
|
||||
|
|
Loading…
Reference in New Issue