Skip to content

Commit

Permalink
Merge 0923339 into 80373ed
Browse files Browse the repository at this point in the history
  • Loading branch information
lvisei committed Feb 2, 2023
2 parents 80373ed + 0923339 commit 0d5cb80
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 31 deletions.
@@ -1,9 +1,9 @@
import { IconFontLayerOptions } from './types';
import { CompositeLayer } from '../../core/composite-layer';
import { CompositeLayerEvent, LayerGroupEvent } from '../../core/constants';
import { Scene } from '../../types';
import { DEFAULT_OPTIONS } from './constants';
import { IconLayer } from './icon';
import { CompositeLayerEvent } from '../../core/constants';
import { CompositeLayer } from '../../core/composite-layer';
import { IconFontLayerOptions } from './types';

export class IconFontLayer extends IconLayer<IconFontLayerOptions> {
/**
Expand All @@ -25,13 +25,18 @@ export class IconFontLayer extends IconLayer<IconFontLayerOptions> {
public addTo(scene: Scene) {
this.scene = scene;
this.initAssets();
if (this.fontLoaded) {
const callback = () => {
this.subLayers.once(LayerGroupEvent.INITED_LAYERS, () => {
this.emit(CompositeLayerEvent.INITED, this);
this.emit(CompositeLayerEvent.ADD, this);
});
this.subLayers.addTo(scene);
this.emit(CompositeLayerEvent.ADD);
};
if (this.fontLoaded) {
callback();
} else {
this.on('fontloaded', () => {
this.subLayers.addTo(scene);
this.emit(CompositeLayerEvent.ADD);
callback();
});
}
}
Expand Down
@@ -1,9 +1,9 @@
import { IconImageLayerOptions } from './types';
import { CompositeLayer } from '../../core/composite-layer';
import { CompositeLayerEvent, LayerGroupEvent } from '../../core/constants';
import { Scene } from '../../types';
import { DEFAULT_OPTIONS } from './constants';
import { IconLayer } from './icon';
import { Scene } from '../../types';
import { CompositeLayerEvent } from '../../core/constants';
import { CompositeLayer } from '../../core/composite-layer';
import { IconImageLayerOptions } from './types';

export class IconImageLayer extends IconLayer<IconImageLayerOptions> {
/**
Expand All @@ -21,8 +21,11 @@ export class IconImageLayer extends IconLayer<IconImageLayerOptions> {
public addTo(scene: Scene) {
this.scene = scene;
this.initAssets().then(() => {
this.subLayers.once(LayerGroupEvent.INITED_LAYERS, () => {
this.emit(CompositeLayerEvent.INITED, this);
this.emit(CompositeLayerEvent.ADD, this);
});
this.subLayers.addTo(scene);
this.emit(CompositeLayerEvent.ADD);
});
}

Expand Down
@@ -1,15 +1,15 @@
import { omit, clone, isEqual, isUndefined } from '@antv/util';
import { CompositeLayer } from '../../core/composite-layer';
import { TextLayer } from '../../core-layers/text-layer';
import { clone, isEqual, isUndefined, omit } from '@antv/util';
import { PointLayer } from '../../core-layers/point-layer';
import { IconLayerOptions, IconLayerActiveOptions, IconLayerSourceOptions } from './types';
import { getDefaultState } from './adaptor';
import { DEFAULT_OPTIONS, DEFAULT_STATE } from './constants';
import { ICoreLayer, Scene, MouseEvent, BlendType, ISource } from '../../types';
import { getLabelLayerOptions } from '../common/label-layer';
import { TextLayer } from '../../core-layers/text-layer';
import { CompositeLayer } from '../../core/composite-layer';
import { CompositeLayerEvent } from '../../core/constants';
import { BlendType, ICoreLayer, ISource, MouseEvent, Scene } from '../../types';
import { EMPTY_JSON_SOURCE } from '../common/constants';
import { getLabelLayerOptions } from '../common/label-layer';
import { isGestureMultiSelect } from '../common/multi-select';
import { getDefaultState } from './adaptor';
import { DEFAULT_OPTIONS, DEFAULT_STATE } from './constants';
import { IconLayerActiveOptions, IconLayerOptions, IconLayerSourceOptions } from './types';

export abstract class IconLayer<T extends IconLayerOptions> extends CompositeLayer<T> {
/**
Expand Down
22 changes: 11 additions & 11 deletions packages/composite-layers/src/core/core-layer.ts
@@ -1,26 +1,26 @@
import { Source } from '@antv/l7';
import EventEmitter from '@antv/event-emitter';
import { isEqual, isUndefined, uniqueId, omit } from '@antv/util';
import { deepMergeLayerOptions, isSourceChanged } from '../utils';
import { Source } from '@antv/l7';
import { isEqual, isUndefined, omit, uniqueId } from '@antv/util';
import { MappingAttribute } from '../adaptor/attribute';
import {
AnimateAttr,
ColorAttr,
ICoreLayer,
ILayer,
LayerBlend,
ILegend,
ISource,
LayerBaseConfig,
LayerBlend,
ScaleAttr,
Scene,
SourceOptions,
ShapeAttr,
ColorAttr,
SizeAttr,
ScaleAttr,
AnimateAttr,
SourceOptions,
StateAttribute,
TextureAttr,
ISource,
ILegend,
} from '../types';
import { deepMergeLayerOptions, isSourceChanged } from '../utils';
import { CoreLayerEvent, OriginLayerEventList } from './constants';
import { MappingAttribute } from '../adaptor/attribute';

/**
* 核心图层的基础配置
Expand Down

0 comments on commit 0d5cb80

Please sign in to comment.