From 2a02861d93aa915c3c5611f4835dfaddd5c4112f Mon Sep 17 00:00:00 2001 From: Lufaneng Date: Wed, 30 Jul 2025 16:09:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E5=88=9D=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components.d.ts | 9 + src/components/MapSelector.md | 89 ++++ src/components/MapSelector.vue | 522 ++++++++++++++++++++++ src/config/map.js | 19 + src/views/BusinessManage/HandleDialog.vue | 88 ++-- src/views/BusinessManage/index.vue | 2 +- src/views/CustomerManage/index.vue | 2 +- 7 files changed, 697 insertions(+), 34 deletions(-) create mode 100644 src/components/MapSelector.md create mode 100644 src/components/MapSelector.vue create mode 100644 src/config/map.js diff --git a/src/components.d.ts b/src/components.d.ts index f46eab1..0aad524 100644 --- a/src/components.d.ts +++ b/src/components.d.ts @@ -7,6 +7,7 @@ export {} /* prettier-ignore */ declare module 'vue' { export interface GlobalComponents { + ElAlert: typeof import('element-plus/es')['ElAlert'] ElAside: typeof import('element-plus/es')['ElAside'] ElBreadcrumb: typeof import('element-plus/es')['ElBreadcrumb'] ElBreadcrumbItem: typeof import('element-plus/es')['ElBreadcrumbItem'] @@ -41,9 +42,17 @@ declare module 'vue' { IEpMessageBox: typeof import('~icons/ep/message-box')['default'] IEpPlus: typeof import('~icons/ep/plus')['default'] IEpScaleToOriginal: typeof import('~icons/ep/scale-to-original')['default'] + MapSelector: typeof import('./components/MapSelector.vue')['default'] + MapSelectorFinal: typeof import('./components/MapSelectorFinal.vue')['default'] + MapSelectorFixed: typeof import('./components/MapSelectorFixed.vue')['default'] + MapSelectorOptimized: typeof import('./components/MapSelectorOptimized.vue')['default'] + MapSelectorSimple: typeof import('./components/MapSelectorSimple.vue')['default'] + MapSelectorWithMarker: typeof import('./components/MapSelectorWithMarker.vue')['default'] + MapTest: typeof import('./components/MapTest.vue')['default'] Pagination: typeof import('./components/Pagination/index.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] + SimpleMapTest: typeof import('./components/SimpleMapTest.vue')['default'] } export interface ComponentCustomProperties { vLoading: typeof import('element-plus/es')['ElLoadingDirective'] diff --git a/src/components/MapSelector.md b/src/components/MapSelector.md new file mode 100644 index 0000000..be585cc --- /dev/null +++ b/src/components/MapSelector.md @@ -0,0 +1,89 @@ +# 腾讯地图坐标选择器使用说明 (基于 tlbs-map-vue) + +## 功能说明 +MapSelector 是一个基于 `tlbs-map-vue` 的坐标选择器组件,用于在地图上选择经纬度坐标。 + +## 技术栈 +- Vue 3 +- tlbs-map-vue (腾讯地图官方 Vue 组件库) +- Element Plus + +## 安装依赖 +```bash +npm install tlbs-map-vue +``` + +## 使用方法 + +### 1. 配置腾讯地图API密钥 +在 `src/config/map.js` 文件中,将 `TENCENT_MAP_KEY` 替换为你的实际API密钥: + +```javascript +export const MAP_CONFIG = { + TENCENT_MAP_KEY: '你的腾讯地图API密钥', + // ...其他配置 +} +``` + +### 2. 获取腾讯地图API密钥 +1. 访问腾讯位置服务官网:https://lbs.qq.com/ +2. 注册并登录账号 +3. 创建应用并获取API密钥(WebServiceAPI密钥) +4. 在控制台中配置域名白名单 + +### 3. 在组件中使用 +```vue + + + +``` + +## Props +- `modelValue`: Boolean - 控制对话框显示/隐藏 +- `longitude`: Number - 初始经度值 +- `latitude`: Number - 初始纬度值 + +## Events +- `update:modelValue`: 更新对话框显示状态 +- `confirm`: 确认选择坐标时触发,返回 `{longitude, latitude}` 对象 + +## 特性 +- ✅ 基于腾讯地图官方 Vue 组件库 +- ✅ 支持点击地图选择坐标 +- ✅ 实时显示选择的经纬度 +- ✅ 支持初始坐标显示 +- ✅ 响应式设计 +- ✅ 自动处理地图加载 + +## 注意事项 +1. 确保已正确配置腾讯地图API密钥 +2. 需要在腾讯地图控制台中配置域名白名单 +3. 在生产环境中建议将API密钥配置在环境变量中 +4. 使用的是 WebServiceAPI 密钥,不是 JavaScript API 密钥 + +## 故障排除 +如果地图无法显示: +1. 检查 API 密钥是否正确 +2. 确认域名已添加到白名单 +3. 检查网络连接 +4. 查看浏览器控制台错误信息 \ No newline at end of file diff --git a/src/components/MapSelector.vue b/src/components/MapSelector.vue new file mode 100644 index 0000000..0b77fb7 --- /dev/null +++ b/src/components/MapSelector.vue @@ -0,0 +1,522 @@ + + + + + \ No newline at end of file diff --git a/src/config/map.js b/src/config/map.js new file mode 100644 index 0000000..94b1acc --- /dev/null +++ b/src/config/map.js @@ -0,0 +1,19 @@ +// 地图配置 +export const MAP_CONFIG = { + // 腾讯地图API密钥 - 请替换为你的实际密钥 + TENCENT_MAP_KEY: 'HGWBZ-QUB6Z-C7KXZ-TJRCH-IFLLO-AMFIJ', + + // 默认地图中心点(北京) + DEFAULT_CENTER: { + latitude: 39.916527, + longitude: 116.397128 + }, + + // 默认缩放级别 + DEFAULT_ZOOM: 13 +} + +// 注意: +// 1. 请到腾讯位置服务官网申请API密钥:https://lbs.qq.com/ +// 2. 将上面的 YOUR_TENCENT_MAP_API_KEY 替换为你的实际密钥 +// 3. 在生产环境中,建议将密钥配置在环境变量中 \ No newline at end of file diff --git a/src/views/BusinessManage/HandleDialog.vue b/src/views/BusinessManage/HandleDialog.vue index a8c26bf..7d83df6 100644 --- a/src/views/BusinessManage/HandleDialog.vue +++ b/src/views/BusinessManage/HandleDialog.vue @@ -1,5 +1,7 @@ diff --git a/src/views/BusinessManage/index.vue b/src/views/BusinessManage/index.vue index 42e5424..f65410a 100644 --- a/src/views/BusinessManage/index.vue +++ b/src/views/BusinessManage/index.vue @@ -46,7 +46,7 @@ - + diff --git a/src/views/CustomerManage/index.vue b/src/views/CustomerManage/index.vue index f62d5c5..959c938 100644 --- a/src/views/CustomerManage/index.vue +++ b/src/views/CustomerManage/index.vue @@ -53,7 +53,7 @@ - +