mirror of https://gitee.com/antv-l7/antv-l7
Feat source (#765)
* feat: layer 初始化支持传入source 对象 * fix: l7 导出source * fix: lint error Co-authored-by: 象数 <zhengxue.lzx@antgroup.com>
This commit is contained in:
parent
02df900784
commit
e37ae61516
|
@ -1,3 +1,4 @@
|
|||
import Source from '@antv/l7-source';
|
||||
export * from '@antv/l7-core';
|
||||
export * from '@antv/l7-scene';
|
||||
export * from '@antv/l7-maps';
|
||||
|
@ -5,3 +6,4 @@ export * from '@antv/l7-layers';
|
|||
export * from '@antv/l7-component';
|
||||
export * from '@antv/l7-utils';
|
||||
export * from './version';
|
||||
export { Source };
|
||||
|
|
|
@ -30,6 +30,7 @@ import {
|
|||
IScale,
|
||||
IScaleOptions,
|
||||
IShaderModuleService,
|
||||
ISource,
|
||||
ISourceCFG,
|
||||
IStyleAttributeInitializationOptions,
|
||||
IStyleAttributeService,
|
||||
|
@ -451,6 +452,11 @@ export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
|
|||
}
|
||||
|
||||
public source(data: any, options?: ISourceCFG): ILayer {
|
||||
if (data?.data) {
|
||||
// 判断是否为source
|
||||
this.setSource(data);
|
||||
return this;
|
||||
}
|
||||
this.sourceOption = {
|
||||
data,
|
||||
options,
|
||||
|
|
|
@ -6,6 +6,7 @@ import {
|
|||
IParseDataItem,
|
||||
IParserCfg,
|
||||
IParserData,
|
||||
ISource,
|
||||
ISourceCFG,
|
||||
ITransform,
|
||||
lazyInject,
|
||||
|
@ -35,7 +36,7 @@ function mergeCustomizer(objValue: any, srcValue: any) {
|
|||
}
|
||||
}
|
||||
|
||||
export default class Source extends EventEmitter {
|
||||
export default class Source extends EventEmitter implements ISource {
|
||||
public data: IParserData;
|
||||
|
||||
// 数据范围
|
||||
|
@ -66,7 +67,7 @@ export default class Source extends EventEmitter {
|
|||
|
||||
private clusterIndex: Supercluster;
|
||||
|
||||
constructor(data: any, cfg?: ISourceCFG) {
|
||||
constructor(data: any | ISource, cfg?: ISourceCFG) {
|
||||
super();
|
||||
// this.rawData = cloneDeep(data);
|
||||
this.originData = data;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// @ts-ignore
|
||||
import {
|
||||
Layers,
|
||||
Source,
|
||||
LineLayer,
|
||||
PointLayer,
|
||||
PolygonLayer,
|
||||
|
@ -43,8 +44,10 @@ export default class World extends React.Component {
|
|||
autoFit: true,
|
||||
});
|
||||
|
||||
const dataSource = new Source(data);
|
||||
|
||||
layer
|
||||
.source(data)
|
||||
.source(dataSource)
|
||||
.color('name', [
|
||||
'#2E8AE6',
|
||||
'#69D1AB',
|
||||
|
@ -65,7 +68,7 @@ export default class World extends React.Component {
|
|||
});
|
||||
|
||||
linelayer
|
||||
.source(data)
|
||||
.source(dataSource)
|
||||
.color('#fff')
|
||||
.size(1)
|
||||
.shape('line')
|
||||
|
|
Loading…
Reference in New Issue