Skip to content

Commit

Permalink
Merge 97169e6 into 5576ff8
Browse files Browse the repository at this point in the history
  • Loading branch information
lvisei committed May 23, 2022
2 parents 5576ff8 + 97169e6 commit 8844b1f
Show file tree
Hide file tree
Showing 16 changed files with 70 additions and 56 deletions.
2 changes: 1 addition & 1 deletion packages/composite-layers/README.md
@@ -1,5 +1,5 @@
<h1 align="center">Composite Layers</h1>

<div align="center">
Composite layers for @antv/l7@antv/l7plot@antv/larkmap@antv/dipper.
Composite layers for @antv/l7@antv/l7plot@antv/lark-map@antv/dipper.
</div>
5 changes: 4 additions & 1 deletion packages/composite-layers/package.json
@@ -1,6 +1,6 @@
{
"name": "@antv/l7-composite-layers",
"version": "0.0.1-alpha.4",
"version": "0.0.1-alpha.5",
"description": "Composite layer for @antv/l7",
"main": "dist/lib/index.js",
"types": "dist/lib/index.d.ts",
Expand Down Expand Up @@ -41,6 +41,9 @@
"@antv/event-emitter": "^0.1.2",
"@antv/util": "^2.0.14"
},
"peerDependencies": {
"@antv/l7": "^2.7.22"
},
"publishConfig": {
"access": "public"
}
Expand Down
Expand Up @@ -7,8 +7,6 @@ import { getDefaultState } from './adaptor';
import { DEFAULT_OPTIONS, DEFAULT_STATE, EMPTY_SOURCE } from './constants';
import { BubbleLayerOptions } from './types';

export type { BubbleLayerOptions };

export class BubbleLayer extends CompositeLayer<BubbleLayerOptions> {
/**
* 默认配置项
Expand Down Expand Up @@ -273,8 +271,6 @@ export class BubbleLayer extends CompositeLayer<BubbleLayerOptions> {
this.labelLayer.setSource(source);
} else {
const { data, ...option } = source;
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
this.source.setData(data, option);
}

Expand All @@ -293,7 +289,7 @@ export class BubbleLayer extends CompositeLayer<BubbleLayerOptions> {
const features = feature ? [feature] : [];
this.highlightStrokeLayer.changeData({
data: features,
parser: this.source['parser'],
parser: this.source.parser,
});
this.highlightData = featureId;
}
Expand All @@ -312,8 +308,8 @@ export class BubbleLayer extends CompositeLayer<BubbleLayerOptions> {
return;
}
const features = selectData.map(({ feature }) => feature);
this.selectFillLayer.changeData({ data: features, parser: this.source['parser'] });
this.selectStrokeLayer.changeData({ data: features, parser: this.source['parser'] });
this.selectFillLayer.changeData({ data: features, parser: this.source.parser });
this.selectStrokeLayer.changeData({ data: features, parser: this.source.parser });
this.selectData = selectData;
}

Expand Down
Expand Up @@ -4,13 +4,13 @@ import { CompositeLayerOptions } from '../../core/composite-layer';
import { ISource, SourceOptions } from '../../types';

export type BubbleLayerActiveOptions = {
// 填充颜色
/** 填充颜色 */
fillColor?: false | string;
// 描边颜色
/** 描边颜色 */
strokeColor?: false | string;
// 描边的宽度
/** 描边的宽度 */
lineWidth?: number;
// 描边透明度
/** 描边透明度 */
lineOpacity?: number;
};

Expand Down Expand Up @@ -51,7 +51,9 @@ export interface BubbleLayerOptions extends CompositeLayerOptions {
* 交互反馈
*/
state?: {
/** 高亮交互 */
active?: boolean | BubbleLayerActiveOptions;
/** 选中交互 */
select?: boolean | BubbleLayerActiveOptions;
};
/**
Expand Down
Expand Up @@ -8,8 +8,6 @@ import { ChoroplethLayerOptions, ChoroplethLayerSourceOptions } from './types';
import { ICoreLayer, ISource, MouseEvent } from '../../types';
import { DEFAULT_OPTIONS, DEFAULT_STATE, EMPTY_SOURCE } from './constants';

export type { ChoroplethLayerOptions };

export class ChoroplethLayer extends CompositeLayer<ChoroplethLayerOptions> {
/**
* 默认配置项
Expand Down Expand Up @@ -297,8 +295,6 @@ export class ChoroplethLayer extends CompositeLayer<ChoroplethLayerOptions> {
this.labelLayer.setSource(source);
} else {
const { data, ...option } = source;
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
this.source.setData(data, option);
}

Expand All @@ -317,7 +313,7 @@ export class ChoroplethLayer extends CompositeLayer<ChoroplethLayerOptions> {
const features = feature ? [feature] : [];
this.highlightStrokeLayer.changeData({
data: { type: 'FeatureCollection', features },
parser: this.source['parser'],
parser: this.source.parser,
});
this.highlightData = featureId;
}
Expand All @@ -336,8 +332,8 @@ export class ChoroplethLayer extends CompositeLayer<ChoroplethLayerOptions> {
return;
}
const features = selectData.map(({ feature }) => feature);
this.selectFillLayer.changeData({ data: { type: 'FeatureCollection', features }, parser: this.source['parser'] });
this.selectStrokeLayer.changeData({ data: { type: 'FeatureCollection', features }, parser: this.source['parser'] });
this.selectFillLayer.changeData({ data: { type: 'FeatureCollection', features }, parser: this.source.parser });
this.selectStrokeLayer.changeData({ data: { type: 'FeatureCollection', features }, parser: this.source.parser });
this.selectData = selectData;
}

Expand Down
Expand Up @@ -7,17 +7,18 @@ import { ISourceCFG, ISource } from '../../types';
* 数据配置
*/
export interface ChoroplethLayerSourceOptions extends Pick<ISourceCFG, 'parser' | 'transforms'> {
/** 数据 */
data: any;
}

export type ChoroplethLayerActiveOptions = {
// 填充颜色
/** 填充颜色 */
fillColor?: false | string;
// 描边颜色
/** 描边颜色 */
strokeColor?: false | string;
// 描边的宽度
/** 描边的宽度 */
lineWidth?: number;
// 描边透明度
/** 描边透明度 */
lineOpacity?: number;
};

Expand Down Expand Up @@ -67,7 +68,9 @@ export interface ChoroplethLayerOptions extends CompositeLayerOptions {
* 交互反馈
*/
state?: {
/** 高亮交互 */
active?: boolean | ChoroplethLayerActiveOptions;
/** 选中交互 */
select?: boolean | ChoroplethLayerActiveOptions;
};
/**
Expand Down
Expand Up @@ -3,8 +3,6 @@ import { CoreLayer } from '../../core/core-layer';
import { ILayer } from '../../types';
import { HeatmapLayerOptions } from './types';

export type { HeatmapLayerOptions };

/**
* 热力图层
* 对应 L7 的 HeatmapLayer
Expand Down
14 changes: 0 additions & 14 deletions packages/composite-layers/src/core-layers/heatmap-layer/types.ts
Expand Up @@ -45,20 +45,6 @@ export type HeatmapShape3d = 'cylinder' | 'squareColumn' | 'hexagonColumn' | 'tr

export type HeatmapShape = 'heatmap' | 'heatmap3D' | HeatmapShape2d | HeatmapShape3d;

/**
* 热力图层基础配置
*/
export interface HeatmapLayerConfig {
/**
* 图形形状
*/
shape?: HeatmapShape;
/**
* 图层样式
*/
style?: HeatmapLayerStyleOptions | GridHeatmapLayerStyleOptions;
}

/**
* 线图层配置
*/
Expand Down
2 changes: 0 additions & 2 deletions packages/composite-layers/src/core-layers/line-layer/index.ts
Expand Up @@ -3,8 +3,6 @@ import { CoreLayer } from '../../core/core-layer';
import { ILayer } from '../../types';
import { LineLayerOptions } from './types';

export type { LineLayerOptions };

/**
* 线图层
* 对应 L7 的 LineLayer
Expand Down
Expand Up @@ -3,8 +3,6 @@ import { CoreLayer } from '../../core/core-layer';
import { ILayer } from '../../types';
import { PointLayerOptions } from './types';

export type { PointLayerOptions };

/**
* 点图层
* 对应 L7 的 PointLayer
Expand Down
Expand Up @@ -3,8 +3,6 @@ import { CoreLayer } from '../../core/core-layer';
import { ILayer } from '../../types';
import { PolygonLayerOptions } from './types';

export type { PolygonLayerOptions };

/**
* 面图层
* 对应 L7 的 PolygonLayer
Expand Down
2 changes: 0 additions & 2 deletions packages/composite-layers/src/core-layers/text-layer/index.ts
Expand Up @@ -3,8 +3,6 @@ import { CoreLayer } from '../../core/core-layer';
import { ILayer } from '../../types';
import { TextLayerOptions } from './types';

export type { TextLayerOptions };

/**
* 文本图层
* 对应 L7 的 PointLayer
Expand Down
13 changes: 13 additions & 0 deletions packages/composite-layers/src/core/composite-layer.ts
Expand Up @@ -9,15 +9,28 @@ import { LayerGroup } from './layer-group';
* 复合图层的基础配置
*/
export interface CompositeLayerOptions {
/** 图层名称 */
name?: string;
/** 图层 ID */
id?: string;
/** 图层 zIndex */
zIndex?: number;
/** 图层是否可见 */
visible?: boolean;
/** 图层最小可见层级 */
minZoom?: number;
/** 图层最大可见层级 */
maxZoom?: number;
/**
* 图层拾取缓存配置,
* 如 1px 宽度的线鼠标很难拾取到, 通过设置该参数可扩大拾取的范围
* */
pickingBuffer?: number;
/** 图层初始化完成之后,地图是否自动缩放到图层范围 */
autoFit?: boolean;
/** 图层元素混合效果 */
blend?: LayerBlend;
/** 数据源 */
source: any;
}

Expand Down
21 changes: 14 additions & 7 deletions packages/composite-layers/src/index.ts
Expand Up @@ -9,18 +9,25 @@ export { LayerGroup, LayerGroupOptions } from './core/layer-group';

/** 核心图层 **/
// 点图层及类型定义 | author by [yunji]](https://github.com/lvisei)
export { PointLayer, PointLayerOptions } from './core-layers/point-layer';
export { PointLayer } from './core-layers/point-layer';
export * from './core-layers/point-layer/types';
// 文本图层及类型定义 | author by [yunji]](https://github.com/lvisei)
export { TextLayer, TextLayerOptions } from './core-layers/text-layer';
export { TextLayer } from './core-layers/text-layer';
export * from './core-layers/text-layer/types';
// 热力图层及类型定义 | author by [yunji]](https://github.com/lvisei)
export { HeatmapLayer, HeatmapLayerOptions } from './core-layers/heatmap-layer';
export { HeatmapLayer } from './core-layers/heatmap-layer';
export * from './core-layers/heatmap-layer/types';
// 线图层及类型定义 | author by [yunji]](https://github.com/lvisei)
export { LineLayer, LineLayerOptions } from './core-layers/line-layer';
export { LineLayer } from './core-layers/line-layer';
export * from './core-layers/line-layer/types';
// 面图层及类型定义 | author by [yunji]](https://github.com/lvisei)
export { PolygonLayer, PolygonLayerOptions } from './core-layers/polygon-layer';
export { PolygonLayer } from './core-layers/polygon-layer';
export * from './core-layers/polygon-layer/types';

/** 复合图层 **/
// 气泡图层及类型定义 | author by [yunji]](https://github.com/lvisei)
export { BubbleLayer, BubbleLayerOptions } from './composite-layers/bubble-layer';
export { BubbleLayer } from './composite-layers/bubble-layer';
export * from './composite-layers/bubble-layer/types';
// 区域图层及类型定义 | author by [yunji]](https://github.com/lvisei)
export { ChoroplethLayer, ChoroplethLayerOptions } from './composite-layers/choropleth-layer';
export { ChoroplethLayer } from './composite-layers/choropleth-layer';
export * from './composite-layers/choropleth-layer/types';
18 changes: 18 additions & 0 deletions packages/composite-layers/src/types/attr.ts
Expand Up @@ -7,36 +7,51 @@ export type Callback<T> = (data: Record<string, any>) => T | T[];
export type ColorsAttr = string | string[];

export type StyleAttribute<T> = {
/** 映射字段 */
field?: string | string[];
/** 映射值 */
value?: T | T[] | Callback<T>;
};

export type ColorStyleAttribute = {
/** 映射字段 */
field?: string | string[];
/** 映射值 */
value?: string | string[] | Callback<string>;
/** scale 配置项 */
scale?: ScaleConfig;
};

export type SizeStyleAttribute = {
/** 映射字段 */
field?: string;
/** 映射值 */
value?: number | number[] | Callback<number | number[]>;
/** scale 配置项 */
scale?: ScaleConfig;
};

export type ShapeStyleAttribute<T> = {
/** 映射字段 */
field?: string | string[];
/** 映射值 */
value?: T | T[] | Callback<T>;
/** scale 配置项 */
scale?: ScaleConfig;
};

export type RotateStyleAttribute = {
/** 映射字段 */
field?: string;
/** 映射值 */
value?: number | number[] | Callback<number>;
};

/** 图形交互反馈 */
export type StateAttribute = {
/** 高亮交互 */
active?: boolean | IActiveOption;
/** 选中交互 */
select?: boolean | IActiveOption;
};

Expand All @@ -63,13 +78,16 @@ export type ScaleAttr = Record<string, ScaleConfig>;

/** 数据过滤 */
export type FilterAttr = {
/** 映射字段 */
field?: string | string[];
/** 映射值 */
value: Callback<boolean>;
};

/**
* 数据配置
*/
export interface SourceOptions extends ISourceCFG {
/** 数据 */
data: any;
}
2 changes: 1 addition & 1 deletion packages/composite-layers/src/version.ts
@@ -1 +1 @@
export default '0.0.1-alpha.4';
export default '0.0.1-alpha.5';

0 comments on commit 8844b1f

Please sign in to comment.