Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 方法导出& 定位优化 #165

Merged
merged 16 commits into from
Dec 19, 2024
Merged
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';
Loading