feat(source): add join transfroms

This commit is contained in:
thinkinggis 2019-12-12 19:42:17 +08:00
parent 87176fb0bc
commit 1ea4af809d
4 changed files with 44 additions and 14 deletions

View File

@ -195,20 +195,20 @@ export default class PixelPickingPass<
feature: unknown;
}) {
const { onHover, onClick } = this.layer.getLayerConfig();
if (onHover) {
onHover({
x,
y,
feature,
});
}
if (onClick) {
onClick({
x,
y,
feature,
});
}
// if (onHover) {
// onHover({
// x,
// y,
// feature,
// });
// }
// if (onClick) {
// onClick({
// x,
// y,
// feature,
// });
// }
this.layer.emit(type, {
x,
y,

View File

@ -5,6 +5,7 @@
"main": "lib/index.js",
"module": "es/index.js",
"types": "es/index.d.ts",
"unpkg": "dist/l7.js",
"sideEffects": true,
"files": [
"dist",

View File

@ -9,6 +9,7 @@ import { cluster } from './transform/cluster';
import { filter } from './transform/filter';
import { aggregatorToGrid } from './transform/grid';
import { pointToHexbin } from './transform/hexagon';
import { join } from './transform/join';
import { map } from './transform/map';
export default Source;
registerParser('geojson', geojson);

View File

@ -0,0 +1,28 @@
import { IParseDataItem, IParserData } from '@antv/l7-core';
interface IJoinOption {
field: 'string';
data: any[];
}
/**
*
* @param data
* @param options
*/
export function filter(geoData: IParserData, options: { [key: string]: any }) {
const { field, data } = options;
const dataObj: { [key: string]: any } = {};
data.forEach((element: { [key: string]: any }) => {
dataObj[element.field] = element;
});
geoData.dataArray = data.dataArray.map((item: IParseDataItem) => {
const joinName = item[field];
return {
...dataObj[joinName],
...item,
};
});
return data;
}