Skip to content

Commit

Permalink
feat: 添加客流图层 (#176)
Browse files Browse the repository at this point in the history
Co-authored-by: yzg1025 <yzg17803834564>
Co-authored-by: websybin <[email protected]>
Co-authored-by: yanxiong <[email protected]>
Co-authored-by: [email protected] <[email protected]>
  • Loading branch information
4 people authored Jun 21, 2023
1 parent 67da61f commit 7237dbf
Show file tree
Hide file tree
Showing 10 changed files with 607 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ yarn.lock
.umi-production
.umi-test
.env.local
.vscode
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/larkmap",
"version": "1.3.7",
"version": "1.4.0",
"description": "A React toolkit for geospatial visualization based on L7",
"license": "MIT",
"main": "lib/index.js",
Expand Down Expand Up @@ -125,4 +125,4 @@
"publishConfig": {
"registry": "https://registry.npmjs.org/"
}
}
}
46 changes: 46 additions & 0 deletions src/components/Layers/CompositeLayers/FlowLayer/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { LayerEventMap } from '../../hooks/use-layer-event/constant';
import type { IMapEvent } from './types';

export const FlowLayerEventMap: IMapEvent = {
// 通用事件
onRemove: LayerEventMap.onRemove,
onShow: LayerEventMap.onShow,
onHide: LayerEventMap.onHide,
onDataUpdate: LayerEventMap.onDataUpdate,
onLegend: LayerEventMap.onLegend,
onLegendColor: LayerEventMap.onLegendColor,
onLegendSize: LayerEventMap.onLegendSize,
// 客流点点击事件
onCircleLayerClick: 'circleLayer:' + LayerEventMap.onClick,
onCircleLayerUnClick: 'circleLayer:' + LayerEventMap.onUnClick,
onCircleLayerDblClick: 'circleLayer:' + LayerEventMap.onDblClick,
onCircleLayerUndblclick: 'circleLayer:' + LayerEventMap.onUndblclick,
onCircleLayerContextMenu: 'circleLayer:' + LayerEventMap.onContextMenu,
onCircleLayerUnContextMenu: 'circleLayer:' + LayerEventMap.onUnContextMenu,
onCircleLayerMouseEnter: 'circleLayer:' + LayerEventMap.onMouseEnter,
onCircleLayerMouseMove: 'circleLayer:' + LayerEventMap.onMouseMove,
onCircleLayerMouseOut: 'circleLayer:' + LayerEventMap.onMouseOut,
onCircleLayerMouseUp: 'circleLayer:' + LayerEventMap.onMouseUp,
onCircleLayerMouseDown: 'circleLayer:' + LayerEventMap.onMouseDown,
onCircleLayerUnMousemove: 'circleLayer:' + LayerEventMap.onUnMousemove,
onCircleLayerUnMouseup: 'circleLayer:' + LayerEventMap.onUnMouseup,
onCircleLayerUnMousedown: 'circleLayer:' + LayerEventMap.onUnMousedown,
onCircleLayerUnPick: 'circleLayer:' + LayerEventMap.onUnPick,

// 客流线点击事件
onLineLayerClick: 'lineLayer:' + LayerEventMap.onClick,
onLineLayerUnClick: 'lineLayer:' + LayerEventMap.onUnClick,
onLineLayerDblClick: 'lineLayer:' + LayerEventMap.onDblClick,
onLineLayerUndblclick: 'lineLayer:' + LayerEventMap.onUndblclick,
onLineLayerContextMenu: 'lineLayer:' + LayerEventMap.onContextMenu,
onLineLayerUnContextMenu: 'lineLayer:' + LayerEventMap.onUnContextMenu,
onLineLayerMouseEnter: 'lineLayer:' + LayerEventMap.onMouseEnter,
onLineLayerMouseMove: 'lineLayer:' + LayerEventMap.onMouseMove,
onLineLayerMouseOut: 'lineLayer:' + LayerEventMap.onMouseOut,
onLineLayerMouseUp: 'lineLayer:' + LayerEventMap.onMouseUp,
onLineLayerMouseDown: 'lineLayer:' + LayerEventMap.onMouseDown,
onLineLayerUnMousemove: 'lineLayer:' + LayerEventMap.onUnMousemove,
onLineLayerUnMouseup: 'lineLayer:' + LayerEventMap.onUnMouseup,
onLineLayerUnMousedown: 'lineLayer:' + LayerEventMap.onUnMousedown,
onLineLayerUnPick: 'lineLayer:' + LayerEventMap.onUnPick,
};
43 changes: 43 additions & 0 deletions src/components/Layers/CompositeLayers/FlowLayer/demos/default.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { FlowLayer, LarkMap } from '@antv/larkmap';
import React, { useEffect, useState } from 'react';

export default () => {
const [source, setSource] = useState({
data: [],
parser: {
type: 'json',
x: 'f_lon',
y: 'f_lat',
x1: 't_lon',
y1: 't_lat',
weight: 'weight',
},
});

useEffect(() => {
fetch('https://gw.alipayobjects.com/os/bmw-prod/f4f3e99a-1d6c-4ab0-b08f-ec730c576b62.json')
.then((response) => response.json())
.then((data: any) => {
setSource((prevState) => ({ ...prevState, data }));
});
}, []);

return (
<LarkMap
mapType="Gaode"
mapOptions={{
style: 'dark',
center: [121.29, 31.14],
}}
style={{ height: '50vh' }}
>
{source.data.length !== 0 && (
<FlowLayer
source={source}
onCircleLayerClick={(e) => console.log('circle layer click', e)}
onLineLayerClick={(e) => console.log('line layer click', e)}
/>
)}
</LarkMap>
);
};
Loading

0 comments on commit 7237dbf

Please sign in to comment.