Skip to content

Commit

Permalink
feat: 方法导出& 定位优化 (#165)
Browse files Browse the repository at this point in the history
* feat: 方法导出& 定位优化

* feat: lint error

* fix: lint fixed

* fix: lint fixed

* fix: bug fixed

* feat: bug fixed

* fix: bug fixed

* fix: lint fixed

* feat: bug fixed

* feat: bug fixed

* feat: bug fixed

* feat: 删除不需要代码

* feat: 依赖删除

* feat: answer fixed

* docs: update note

---------

Co-authored-by: duxinyue.dxy <duxinyue.dxy@antgroup.com>
Co-authored-by: lvisei <yunji.me@outlook.com>
  • Loading branch information
3 people authored Dec 19, 2024
1 parent 65801a7 commit 17f6fde
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/li-analysis-assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"doctor": "father doctor",
"ci": "npm run doctor",
"prettier": "prettier --write \"src/*.{tsx,ts,less,md,json}\"",
"start": "dumi dev"
"start": "export NODE_OPTIONS=--openssl-legacy-provider && dumi dev"
},
"dependencies": {
"@antv/g2": "^5.1.20",
Expand Down
20 changes: 20 additions & 0 deletions packages/li-editor/src/services/app-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,15 @@ class AppService {
return this.getImplementLayer(name)?.defaultVisConfig ?? {};
}

/**
* 获取图层实例
*/
public getInstanceLayerById(id: string) {
const { layersStore } = this.runtimeApp.stateManager;
const layerManager = layersStore.getLayerManager();
return layerManager?.getLayerById(id);
}

/**
* 图层定位到数据可视范围
*/
Expand Down Expand Up @@ -220,6 +229,17 @@ class AppService {
};
}

/**
* 获取地图实例
*/
public getSceneInstance() {
const { mapStore } = this.runtimeApp.stateManager;
const sceneInstance = mapStore.getScene();
if (!sceneInstance) return;

return sceneInstance;
}

/**
* 设置地图 Bounds
* bounds [[minlng,minlat],[maxlng,maxlat]]
Expand Down
1 change: 1 addition & 0 deletions packages/li-editor/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * from './dataset-parser';
export * from './validator';
export * from './widget';
export { getGeoFields, getPointFieldPairs } from './dataset';

export const requestIdleCallback =
window.requestIdleCallback ||
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import Icon, { CopyOutlined, EyeInvisibleOutlined, EyeOutlined, FormOutlined, MoreOutlined } from '@ant-design/icons';
import Icon, {
CopyOutlined,
EyeInvisibleOutlined,
EyeOutlined,
FormOutlined,
MoreOutlined,
FullscreenExitOutlined,
} from '@ant-design/icons';
import type { LayerSchema } from '@antv/li-sdk';
import { getUniqueId } from '@antv/li-sdk';
import type { MenuProps } from 'antd';
Expand Down Expand Up @@ -81,6 +88,13 @@ const LayerItem = ({ layer, dragIcon, onClickLayer }: LayerItemProps) => {
onClickLayer(layer);
},
},
{
key: 'copy',
label: '复制图层',
onClick() {
handleCopyLayer(layer);
},
},
{
key: 'delete',
label: (
Expand All @@ -99,6 +113,10 @@ const LayerItem = ({ layer, dragIcon, onClickLayer }: LayerItemProps) => {
},
];

const handleFitBoundLayer = (_layer: LayerSchema) => {
appService.handleLayerFitBounds(_layer.id);
};

return (
<div className={classnames(prefixCls, styles.layerItem)} style={{ borderLeftColor: visLayer?.color }}>
<div className={classnames(`${prefixCls}__drag-icon`, styles.dragIcon)}>{dragIcon}</div>
Expand Down Expand Up @@ -138,11 +156,11 @@ const LayerItem = ({ layer, dragIcon, onClickLayer }: LayerItemProps) => {
}}
/>
</Tooltip>
<Tooltip title="点击复制图层">
<CopyOutlined
<Tooltip title="点击定位到图层">
<FullscreenExitOutlined
data-comp="layer-actions-item_hover-show"
className={classnames(`${prefixCls}__actions-item`, styles.actionsItem)}
onClick={() => handleCopyLayer(layer)}
onClick={() => handleFitBoundLayer(layer)}
/>
</Tooltip>

Expand Down
1 change: 1 addition & 0 deletions packages/li-sdk/src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ export * from './useLayerList';
export * from './useLayerManager';
export * from './useScene';
export * from './useWidgetProps';
export { useStateManager } from './internal';

0 comments on commit 17f6fde

Please sign in to comment.