From 32edd2ecb1360fba737db173dcd2b170d010e7bd Mon Sep 17 00:00:00 2001 From: syb01094648 Date: Mon, 6 Nov 2023 16:56:28 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20=E5=BA=95=E5=9B=BE=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E8=85=BE=E8=AE=AF=E7=99=BE=E5=BA=A6=E5=9C=B0=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/app-header/base-map/index.tsx | 10 ++++++++++ src/locales/langs/en-US.ts | 2 ++ src/locales/langs/zh-CN.ts | 6 ++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/components/app-header/base-map/index.tsx b/src/components/app-header/base-map/index.tsx index 1a3fa41..1339c3d 100644 --- a/src/components/app-header/base-map/index.tsx +++ b/src/components/app-header/base-map/index.tsx @@ -27,6 +27,16 @@ export const BaseMap = () => { label: 'Mapbox', value: 'Mapbox', }, + { + img: 'https://mdn.alipayobjects.com/huamei_k6sfo0/afts/img/A*YKJtR5vfbtIAAAAAAAAAAAAADjWqAQ/original', + label: t('btn.setting_btn.tencent'), + value: 'Tencent', + }, + { + img: 'https://mdn.alipayobjects.com/huamei_k6sfo0/afts/img/A*kRvdTLte60cAAAAAAAAAAAAADjWqAQ/original', + label: t('btn.setting_btn.baidu'), + value: 'Baidu', + } ]; const handleChange = (e: 'Gaode' | 'Mapbox') => { diff --git a/src/locales/langs/en-US.ts b/src/locales/langs/en-US.ts index 14ec994..99b8734 100644 --- a/src/locales/langs/en-US.ts +++ b/src/locales/langs/en-US.ts @@ -6,6 +6,8 @@ export default { 'btn.setting_btn.kaiQi': 'Open', 'btn.setting_btn.shiFouZhanShiYuan': 'Display serial number on layer', 'btn.setting_btn.gaoDe': 'Gaode', + 'btn.setting_btn.tencent': 'Tencent', + 'btn.setting_btn.baidu': 'Baidu', 'btn.setting_btn.diTuDiTuQie': 'Switch base map', 'btn.setting_btn.ziDongSuoFangZhi': 'Auto zoom to all elements visible', 'btn.setting_btn.huaRu': 'Mouse on', diff --git a/src/locales/langs/zh-CN.ts b/src/locales/langs/zh-CN.ts index bcd21b8..71abdd2 100644 --- a/src/locales/langs/zh-CN.ts +++ b/src/locales/langs/zh-CN.ts @@ -6,6 +6,8 @@ export default { 'btn.setting_btn.kaiQi': '开启', 'btn.setting_btn.shiFouZhanShiYuan': '是否展示元素序号', 'btn.setting_btn.gaoDe': '高德', + 'btn.setting_btn.tencent': '腾讯', + 'btn.setting_btn.baidu': '百度', 'btn.setting_btn.diTuDiTuQie': '地图底图切换', 'btn.setting_btn.ziDongSuoFangZhi': '自动缩放至所有元素可见', 'btn.setting_btn.huaRu': '划入', @@ -94,7 +96,7 @@ export default { 'app_header.constants.xiaZaiGEO': '下载 GeoJSON 格式数据', 'app_header.constants.zuJianAPI': '组件API文档', 'app_header.constants.pingTaiShiYongWen': '平台使用文档', - 'app_header.constants.issue':'提交 Issue', + 'app_header.constants.issue': '提交 Issue', 'app_header.index.an': '暗', 'app_header.index.liang': '亮', 'app_header.index.yinDao': '引导', @@ -106,7 +108,7 @@ export default { 'app_table.index.xuHao': '序号', 'app_table.index.shanChuLie': '确认删除此列数据?', 'app_table.index.tianJiaLieZiDuan': '添加列字段', - 'app_table.index.ziDuanMing':'字段名:', + 'app_table.index.ziDuanMing': '字段名:', 'app_table.index.qingShuRuLieZiDuan': '请输入列字段', 'geojson_editor.index.jiaoBenShuJuYou': '脚本数据有误', 'geojson_editor.index.xinXi': '信息', From a3b22819374af0629307a953d02dac743c8c6319 Mon Sep 17 00:00:00 2001 From: syb01094648 Date: Tue, 20 Feb 2024 17:12:16 +0800 Subject: [PATCH 2/5] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/app-header/index.tsx | 2 +- src/utils/gcoord.ts | 32 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/components/app-header/index.tsx b/src/components/app-header/index.tsx index b113abf..7f516e6 100644 --- a/src/components/app-header/index.tsx +++ b/src/components/app-header/index.tsx @@ -294,7 +294,7 @@ export const AppHeader: React.FC = ({ toolbar }) => { { + onClick: ({ key }: any) => { onDownload(key); }, }} diff --git a/src/utils/gcoord.ts b/src/utils/gcoord.ts index e369824..7cd03db 100644 --- a/src/utils/gcoord.ts +++ b/src/utils/gcoord.ts @@ -16,3 +16,35 @@ export const gcj02towgs84 = (feature: Feature) => { // @ts-ignore return gcoord.transform(feature, gcoord.GCJ02, gcoord.WGS84) as Feature; }; + +export const gcj02tobd09 = (feature: Feature) => { + if (feature.geometry.type.match(/polygon/i)) { + feature.geometry = JSON.parse(JSON.stringify(feature.geometry)); + } + // @ts-ignore + return gcoord.transform(feature, gcoord.GCJ02, gcoord.BD09) as Feature; +}; + +export const bd09togcj02 = (feature: Feature) => { + if (feature.geometry.type.match(/polygon/i)) { + feature.geometry = JSON.parse(JSON.stringify(feature.geometry)); + } + // @ts-ignore + return gcoord.transform(feature, gcoord.BD09, gcoord.GCJ02) as Feature; +}; + +export const wgs84tobd09 = (feature: Feature) => { + if (feature.geometry.type.match(/polygon/i)) { + feature.geometry = JSON.parse(JSON.stringify(feature.geometry)); + } + // @ts-ignore + return gcoord.transform(feature, gcoord.WGS84, gcoord.BD09) as Feature; +}; + +export const bd09towgs84 = (feature: Feature) => { + if (feature.geometry.type.match(/polygon/i)) { + feature.geometry = JSON.parse(JSON.stringify(feature.geometry)); + } + // @ts-ignore + return gcoord.transform(feature, gcoord.BD09, gcoord.WGS84) as Feature; +}; From 9cbf45753aaf1e02e9b0ab71e8bd7ac7eead637b Mon Sep 17 00:00:00 2001 From: syb01094648 Date: Thu, 22 Feb 2024 16:31:42 +0800 Subject: [PATCH 3/5] =?UTF-8?q?fix:=20=E7=99=BE=E5=BA=A6=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E5=9D=90=E6=A0=87=E7=B3=BB=E8=BD=AC=E6=8D=A2=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/app-header/base-map/index.tsx | 6 ++-- src/components/app-map/index.tsx | 10 +++++- src/components/map-content/index.tsx | 1 + src/components/map-control-group/index.tsx | 3 +- src/constants/index.ts | 5 +++ src/recoil/atomState.ts | 6 ++-- src/recoil/feature.ts | 36 ++++++++++++++++++-- 7 files changed, 56 insertions(+), 11 deletions(-) diff --git a/src/components/app-header/base-map/index.tsx b/src/components/app-header/base-map/index.tsx index 1339c3d..4f7a098 100644 --- a/src/components/app-header/base-map/index.tsx +++ b/src/components/app-header/base-map/index.tsx @@ -36,16 +36,16 @@ export const BaseMap = () => { img: 'https://mdn.alipayobjects.com/huamei_k6sfo0/afts/img/A*kRvdTLte60cAAAAAAAAAAAAADjWqAQ/original', label: t('btn.setting_btn.baidu'), value: 'Baidu', - } + }, ]; - const handleChange = (e: 'Gaode' | 'Mapbox') => { + const handleChange = (e: 'Gaode' | 'Mapbox' | 'Baidu' | 'Tencent') => { setBaseMap(e); setMapOptions({ ...mapOptions, style: theme === 'dark' ? 'dark' : 'normal', }); - setCoordConvert(e === 'Gaode' ? 'GCJ02' : 'WGS84'); + setCoordConvert(e === 'Gaode' ? 'GCJ02' : e === 'Baidu' ? 'BD09' : 'WGS84'); if (e !== baseMap) { location.reload(); } diff --git a/src/components/app-map/index.tsx b/src/components/app-map/index.tsx index e900490..b4ad5e1 100644 --- a/src/components/app-map/index.tsx +++ b/src/components/app-map/index.tsx @@ -4,7 +4,7 @@ import { message } from 'antd'; import type { ReactNode } from 'react'; import React, { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; -import { GaodeConfig, MapBoxConfig } from '../../constants'; +import { BaiduConfig, GaodeConfig, MapBoxConfig } from '../../constants'; import { useFeature, useGlobal } from '../../recoil'; import { getParamsNew, getUrlFeatureCollection } from '../../utils'; import { prettierText } from '../../utils/prettier-text'; @@ -41,12 +41,20 @@ export const AppMap: React.FC = ({ children }) => { ...baseMapOptions, }; } + if (baseMap === 'Baidu') { + return { + ...BaiduConfig, + // ...baseMapOptions, + }; + } return { ...GaodeConfig, ...baseMapOptions, }; }, [baseMap, baseMapOptions]); + console.log(mapOptions) + return ( = ({ options={[ { label: 'GCJ02', value: 'GCJ02' }, { label: 'WGS84', value: 'WGS84' }, + { label: 'BD09', value: 'BD09' }, ]} onChange={setCoordConvert} /> diff --git a/src/components/map-control-group/index.tsx b/src/components/map-control-group/index.tsx index 6d36da8..c604422 100644 --- a/src/components/map-control-group/index.tsx +++ b/src/components/map-control-group/index.tsx @@ -85,7 +85,8 @@ export const MapControlGroup: React.FC = ({ {baseMap === 'Gaode' && isControlGroupState.officialLayerControl && ( )} - {isControlGroupState.mapThemeControl && } + {isControlGroupState.mapThemeControl && + (baseMap === 'Gaode' || baseMap === 'Mapbox') && } {isControlGroupState.geoLocateControl && ( )} diff --git a/src/constants/index.ts b/src/constants/index.ts index ece62d2..8820a4d 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -52,6 +52,11 @@ export const GaodeConfig = { token: '5ae4492ef912cbbc93034fea0e66ff2a', }; +export const BaiduConfig = { + token: '2TVUvWQGt8J3HwJpkZ4qVLYBVpxzudTa', +}; + + export const LayerZIndex = 100; export const GOOGLE_TILE_MAP_URL = diff --git a/src/recoil/atomState.ts b/src/recoil/atomState.ts index c8d3cf1..3bbe5d4 100644 --- a/src/recoil/atomState.ts +++ b/src/recoil/atomState.ts @@ -125,7 +125,7 @@ const popupTriggerState = atom<'click' | 'hover'>({ effects: [localStorageEffect(LocalStorageKey.PopupTrigger)], }); -const baseMapState = atom<'Gaode' | 'Mapbox'>({ +const baseMapState = atom<'Gaode' | 'Mapbox' | 'Baidu' | 'Tencent'>({ key: 'baseMap', effects: [localStorageEffect(LocalStorageKey.BaseMap)], }); @@ -199,13 +199,11 @@ const wasmPathState = atom({ export { activeTabState, - showDrawAreaState, autoFitBoundsState, baseMapState, cityHistoryState, convertState, customTilesState, - showDrawDistanceState, editorTextState, featureState, filterState, @@ -221,6 +219,8 @@ export { rightWidthState, savedTextState, sceneState, + showDrawAreaState, + showDrawDistanceState, showTextLayerState, textLayerFieldsState, themeState, diff --git a/src/recoil/feature.ts b/src/recoil/feature.ts index dd0d7c0..1b43eab 100644 --- a/src/recoil/feature.ts +++ b/src/recoil/feature.ts @@ -7,7 +7,15 @@ import { useTranslation } from 'react-i18next'; import { useRecoilState } from 'recoil'; import { FeatureKey } from '../constants'; import type { FilterField, IFeatures } from '../types'; -import { gcj02towgs84, transformFeatures, wgs84togcj02 } from '../utils'; +import { + bd09togcj02, + bd09towgs84, + gcj02tobd09, + gcj02towgs84, + transformFeatures, + wgs84tobd09, + wgs84togcj02, +} from '../utils'; import { prettierText } from '../utils/prettier-text'; import { editorTextState, @@ -145,7 +153,10 @@ export default function useFeature() { const revertCoord = useCallback( (newFeatures: Feature[]) => { let data = [...newFeatures]; - if (coordConvert === 'WGS84' && baseMap === 'Gaode') { + if ( + coordConvert === 'WGS84' && + (baseMap === 'Gaode' || baseMap === 'Tencent') + ) { data = data.map((item) => { return gcj02towgs84(cloneDeep(item)); }); @@ -153,6 +164,25 @@ export default function useFeature() { data = data.map((item) => { return wgs84togcj02(cloneDeep(item)); }); + } else if (coordConvert === 'GCJ02' && baseMap === 'Baidu') { + data = data.map((item) => { + return bd09togcj02(cloneDeep(item)); + }); + } else if (coordConvert === 'WGS84' && baseMap === 'Baidu') { + data = data.map((item) => { + return bd09towgs84(cloneDeep(item)); + }); + } else if ( + coordConvert === 'BD09' && + (baseMap === 'Gaode' || baseMap === 'Tencent') + ) { + data = data.map((item) => { + return gcj02tobd09(cloneDeep(item)); + }); + } else if (coordConvert === 'BD09' && baseMap === 'Mapbox') { + data = data.map((item) => { + return wgs84tobd09(cloneDeep(item)); + }); } return data; }, @@ -195,4 +225,4 @@ export default function useFeature() { transformCoord, revertCoord, }; -} \ No newline at end of file +} From 9476fedc353e93e2edaa7206a325f5fc79428675 Mon Sep 17 00:00:00 2001 From: syb01094648 Date: Mon, 11 Mar 2024 10:36:12 +0800 Subject: [PATCH 4/5] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=85=BE?= =?UTF-8?q?=E8=AE=AF=E5=9C=B0=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/app-map/index.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/app-map/index.tsx b/src/components/app-map/index.tsx index b4ad5e1..e6e6b21 100644 --- a/src/components/app-map/index.tsx +++ b/src/components/app-map/index.tsx @@ -47,14 +47,17 @@ export const AppMap: React.FC = ({ children }) => { // ...baseMapOptions, }; } + if (baseMap === 'Tencent') { + return { + ...baseMapOptions, + }; + } return { ...GaodeConfig, ...baseMapOptions, }; }, [baseMap, baseMapOptions]); - console.log(mapOptions) - return ( Date: Mon, 11 Mar 2024 15:50:03 +0800 Subject: [PATCH 5/5] =?UTF-8?q?fix:=20=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/app-map/index.tsx | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/components/app-map/index.tsx b/src/components/app-map/index.tsx index e6e6b21..0c9b007 100644 --- a/src/components/app-map/index.tsx +++ b/src/components/app-map/index.tsx @@ -35,25 +35,16 @@ export const AppMap: React.FC = ({ children }) => { }); const mapOptions = useMemo(() => { - if (baseMap === 'Mapbox') { - return { - ...MapBoxConfig, - ...baseMapOptions, - }; - } - if (baseMap === 'Baidu') { - return { - ...BaiduConfig, - // ...baseMapOptions, - }; - } - if (baseMap === 'Tencent') { - return { - ...baseMapOptions, - }; - } + const mapConfigMapping = { + Mapbox: MapBoxConfig, + Baidu: BaiduConfig, + Tencent: {}, + } as any; + + const config = mapConfigMapping[baseMap] || GaodeConfig; + return { - ...GaodeConfig, + ...config, ...baseMapOptions, }; }, [baseMap, baseMapOptions]);