diff --git a/docs/docs/index.md b/docs/docs/index.md index f42f55a..1868031 100644 --- a/docs/docs/index.md +++ b/docs/docs/index.md @@ -37,7 +37,8 @@ title: API | mapControl | 控件显隐 | [MapControlProps](#mapcontrolprops) | `-` | | toolbar | 头部组件显隐 | [ToolbarProps](#toolbarprops) | `-` | | tabItems | 侧面版标签页选项卡内容 | [TabItemType](https://ant-design.antgroup.com/components/tabs-cn#tabitemtype) | `-` | -| showIndex | 是否展示元素序号 | `boolean` | `false` | +| showTextLayer | 是否展示元素文本 | `boolean` | `false` | +| textLayerFields | 展示元素文本的字段,不选则展示元素序号 | `string[] | undefined` | `undefined` | | wasmPath | sam 组件的 wasm 路径 | `string` | `\` | #### `tabItems` @@ -152,6 +153,7 @@ LngLat 文本编辑器,可以通过输入 LngLat 数据实现数据展示(目 | administrativeSelectControl | 行政区域选择控件 | | mapAdministrativeControl | 查看当前行政区域控件 | | logoControl | Logo 控件 | +| textLayerControl | 文本图层 控件 | #### toolbar diff --git a/package.json b/package.json index 6669d0d..4ad586a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@antv/l7-editor", - "version": "1.1.8", + "version": "1.1.9", "description": "Geographic data editing tool based on L7", "files": [ "lib", diff --git a/src/components/app-header/btn/setting-btn.tsx b/src/components/app-header/btn/setting-btn.tsx index 1567ae5..d7ba737 100644 --- a/src/components/app-header/btn/setting-btn.tsx +++ b/src/components/app-header/btn/setting-btn.tsx @@ -6,14 +6,8 @@ import { useGlobal } from '../../../recoil'; export const SettingBtn = () => { const [isModalOpen, setIsModalOpen] = useState(false); - const { - popupTrigger, - setPopupTrigger, - autoFitBounds, - setAutoFitBounds, - showIndex, - setShowIndex - } = useGlobal(); + const { popupTrigger, setPopupTrigger, autoFitBounds, setAutoFitBounds } = + useGlobal(); const { t } = useTranslation(); const [form] = Form.useForm(); @@ -55,14 +49,12 @@ export const SettingBtn = () => { initialValues={{ popupTrigger, autoFitBounds, - showIndex, }} style={{ textAlign: 'right' }} onFinish={(e) => { setIsModalOpen(false); setPopupTrigger(e.popupTrigger); setAutoFitBounds(e.autoFitBounds); - setShowIndex(e.showIndex) }} > { > - - - - {t('btn.setting_btn.kaiQi')} - - - {t('btn.setting_btn.guanBi')} - - - diff --git a/src/components/app-header/index.tsx b/src/components/app-header/index.tsx index 2b705a8..638e5f8 100644 --- a/src/components/app-header/index.tsx +++ b/src/components/app-header/index.tsx @@ -209,6 +209,11 @@ export const AppHeader: React.FC = ({ toolbar }) => { description: t('app_header.constants.keXuanZeBuTong'), target: () => document.getElementById('l7-editor-aMap')!, }, + { + title: t('text-layer-control_wenBenTuCengPeiZhi'), + description: t('text-layer-control_description'), + target: () => document.getElementById('text-layer-control')!, + }, { title: t('app_header.constants.gEOJS'), description: t('app_header.constants.keYiTongGuoBian'), diff --git a/src/components/layer-list/index.tsx b/src/components/layer-list/index.tsx index d3a17cd..9c55bbe 100644 --- a/src/components/layer-list/index.tsx +++ b/src/components/layer-list/index.tsx @@ -15,11 +15,12 @@ import { FeatureKey, LayerId, LayerZIndex } from '../../constants'; import { useFilterFeatures } from '../../hooks'; import { useFeature, useGlobal } from '../../recoil'; import { getPointImage } from '../../utils/change-image-color'; +import { EditorTextLayer } from '../text-layer'; export const LayerList: React.FC = () => { const scene = useScene(); const [isMounted, setIsMounted] = useState(false); - const { layerColor, coordConvert, baseMap } = useGlobal(); + const { layerColor, coordConvert, baseMap, showTextLayer } = useGlobal(); const { transformCoord } = useFeature(); const { features: newFeatures } = useFilterFeatures(); const [features, setFeatures] = useState([]); @@ -111,6 +112,7 @@ export const LayerList: React.FC = () => { state={{ active: { color: activeColor } }} zIndex={LayerZIndex} /> + {showTextLayer && } ) : null; }; diff --git a/src/components/map-control-group/index.tsx b/src/components/map-control-group/index.tsx index f4abd5b..6d36da8 100644 --- a/src/components/map-control-group/index.tsx +++ b/src/components/map-control-group/index.tsx @@ -22,6 +22,7 @@ import MapThemeControl from './map-theme-control'; import { OfficialLayerControl } from './official-layer-control'; import { SamControl } from './sam-control'; import useStyles from './styles'; +import { TextLayerControl } from './text-layer-control'; type MapControlGroupProps = { mapControl?: MapControlProps; @@ -43,6 +44,7 @@ const DefaultMapControl: MapControlProps = { administrativeSelectControl: true, mapAdministrativeControl: true, logoControl: true, + textLayerControl: true, }; export const MapControlGroup: React.FC = ({ mapControl, @@ -70,7 +72,7 @@ export const MapControlGroup: React.FC = ({ {isControlGroupState.drawControl && } {isControlGroupState.clearControl && } {isControlGroupState.zoomControl && ( - + )} {isControlGroupState.mapAdministrativeControl && ( @@ -96,6 +98,7 @@ export const MapControlGroup: React.FC = ({ /> )} {layerType.includes(OfficeLayerEnum.GoogleSatellite) && } + {isControlGroupState.textLayerControl && } ); }; diff --git a/src/components/map-control-group/official-layer-control/index.tsx b/src/components/map-control-group/official-layer-control/index.tsx index 04afa7a..a2db7ad 100644 --- a/src/components/map-control-group/official-layer-control/index.tsx +++ b/src/components/map-control-group/official-layer-control/index.tsx @@ -242,7 +242,7 @@ export function OfficialLayerControl() { return ( <> -
+
{ diff --git a/src/components/map-control-group/official-layer-control/styles.ts b/src/components/map-control-group/official-layer-control/styles.ts index 5286b8f..2c77d74 100644 --- a/src/components/map-control-group/official-layer-control/styles.ts +++ b/src/components/map-control-group/official-layer-control/styles.ts @@ -26,7 +26,7 @@ const useStyle = () => { `, hideOfficeLayerBtn: css` height: 127px; - width: 20px; + width: 28px; display: flex; align-items: center; justify-content: center; diff --git a/src/components/map-control-group/text-layer-control/index.tsx b/src/components/map-control-group/text-layer-control/index.tsx new file mode 100644 index 0000000..590fca1 --- /dev/null +++ b/src/components/map-control-group/text-layer-control/index.tsx @@ -0,0 +1,80 @@ +import { CustomControl } from '@antv/larkmap'; +import { Form, Popover, Select, Switch, Tooltip } from 'antd'; +import React, { useState } from 'react'; +import { useTranslation } from 'react-i18next'; +import { useFeature, useGlobal } from '../../../recoil'; +import { IconFont } from '../../iconfont'; +import useStyles from '../styles'; +import useStyle from './style'; + +export type TextLayerControlProps = {}; + +export const TextLayerControl: React.FC = () => { + const styles = useStyles(); + const style = useStyle(); + const { + showTextLayer, + setShowTextLayer, + textLayerFields, + setTextLayerFields, + } = useGlobal(); + const { features } = useFeature(); + const [fields, setFields] = useState([]); + const { t } = useTranslation(); + + const refreshFields = () => { + const newFieldSet = new Set(); + features.forEach((feature) => { + const properties = feature.properties; + if (properties) { + Object.keys(properties).forEach((key) => { + newFieldSet.add(key); + }); + } + }); + setFields(Array.from(newFieldSet)); + }; + + return ( + + + + + + + +