Showing
2 changed files
with
20 additions
and
10 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2023-05-31 16:10:33 | 2 | * @Date: 2023-05-31 16:10:33 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-03-06 10:16:37 | 4 | + * @LastEditTime: 2025-09-18 09:49:26 |
| 5 | * @FilePath: /map-demo/index.html | 5 | * @FilePath: /map-demo/index.html |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -11,7 +11,7 @@ | ... | @@ -11,7 +11,7 @@ |
| 11 | <meta charset="UTF-8"> | 11 | <meta charset="UTF-8"> |
| 12 | <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover" /> | 12 | <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover" /> |
| 13 | <link rel="shortcut icon" href="favicon.ico" type="image/x-icon"> | 13 | <link rel="shortcut icon" href="favicon.ico" type="image/x-icon"> |
| 14 | - <title></title> | 14 | + <title>地图加载中...</title> |
| 15 | <!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.compat.css" /> --> | 15 | <!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.compat.css" /> --> |
| 16 | </head> | 16 | </head> |
| 17 | <body> | 17 | <body> | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2023-05-19 14:54:27 | 2 | * @Date: 2023-05-19 14:54:27 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-09-08 10:46:16 | 4 | + * @LastEditTime: 2025-09-18 09:52:28 |
| 5 | * @FilePath: /map-demo/src/views/checkin/map.vue | 5 | * @FilePath: /map-demo/src/views/checkin/map.vue |
| 6 | * @Description: 公众地图主体页面 | 6 | * @Description: 公众地图主体页面 |
| 7 | --> | 7 | --> |
| ... | @@ -189,6 +189,13 @@ export default { | ... | @@ -189,6 +189,13 @@ export default { |
| 189 | */ | 189 | */ |
| 190 | mapHeight() { | 190 | mapHeight() { |
| 191 | return this.isMiniProgramWebView ? 'calc(100vh - 80px)' : '100vh'; | 191 | return this.isMiniProgramWebView ? 'calc(100vh - 80px)' : '100vh'; |
| 192 | + }, | ||
| 193 | + /** | ||
| 194 | + * 获取地图缩放级别 | ||
| 195 | + * @returns {number} 地图缩放级别 | ||
| 196 | + */ | ||
| 197 | + zoom() { | ||
| 198 | + return this.data_zoom; | ||
| 192 | } | 199 | } |
| 193 | }, | 200 | }, |
| 194 | data() { | 201 | data() { |
| ... | @@ -312,6 +319,9 @@ export default { | ... | @@ -312,6 +319,9 @@ export default { |
| 312 | } | 319 | } |
| 313 | }, | 320 | }, |
| 314 | async mounted() { | 321 | async mounted() { |
| 322 | + // 设置默认标题,避免显示undefined | ||
| 323 | + document.title = '地图加载中...'; | ||
| 324 | + | ||
| 315 | const AMap = await AMapLoader.load({ | 325 | const AMap = await AMapLoader.load({ |
| 316 | key: '17b8fc386104b89db88b60b049a6dbce', // 控制台获取 | 326 | key: '17b8fc386104b89db88b60b049a6dbce', // 控制台获取 |
| 317 | version: '2.0', // 指定API版本 | 327 | version: '2.0', // 指定API版本 |
| ... | @@ -424,7 +434,7 @@ export default { | ... | @@ -424,7 +434,7 @@ export default { |
| 424 | createMarkerContent(entityInfo, textDirection, isSelected) { | 434 | createMarkerContent(entityInfo, textDirection, isSelected) { |
| 425 | const iconUrl = entityInfo.icon || ''; | 435 | const iconUrl = entityInfo.icon || ''; |
| 426 | const name = entityInfo.name || ''; | 436 | const name = entityInfo.name || ''; |
| 427 | - | 437 | + |
| 428 | // 根据选中状态和文字方向选择样式 | 438 | // 根据选中状态和文字方向选择样式 |
| 429 | let textStyle, containerStyle; | 439 | let textStyle, containerStyle; |
| 430 | if (textDirection === 'vertical') { | 440 | if (textDirection === 'vertical') { |
| ... | @@ -434,12 +444,12 @@ export default { | ... | @@ -434,12 +444,12 @@ export default { |
| 434 | textStyle = isSelected ? this.markerStyle2_horizontal : this.markerStyle1_horizontal; | 444 | textStyle = isSelected ? this.markerStyle2_horizontal : this.markerStyle1_horizontal; |
| 435 | containerStyle = 'flex-direction: row; align-items: center;'; | 445 | containerStyle = 'flex-direction: row; align-items: center;'; |
| 436 | } | 446 | } |
| 437 | - | 447 | + |
| 438 | // 将样式对象转换为CSS字符串 | 448 | // 将样式对象转换为CSS字符串 |
| 439 | const textStyleStr = Object.entries(textStyle) | 449 | const textStyleStr = Object.entries(textStyle) |
| 440 | .map(([key, value]) => `${key}: ${value}`) | 450 | .map(([key, value]) => `${key}: ${value}`) |
| 441 | .join('; '); | 451 | .join('; '); |
| 442 | - | 452 | + |
| 443 | // 创建HTML内容 | 453 | // 创建HTML内容 |
| 444 | const html = ` | 454 | const html = ` |
| 445 | <div style="display: flex; ${containerStyle} cursor: pointer;"> | 455 | <div style="display: flex; ${containerStyle} cursor: pointer;"> |
| ... | @@ -447,7 +457,7 @@ export default { | ... | @@ -447,7 +457,7 @@ export default { |
| 447 | <div style="${textStyleStr}">${name}</div> | 457 | <div style="${textStyleStr}">${name}</div> |
| 448 | </div> | 458 | </div> |
| 449 | `; | 459 | `; |
| 450 | - | 460 | + |
| 451 | return html; | 461 | return html; |
| 452 | }, | 462 | }, |
| 453 | initMap() { | 463 | initMap() { |
| ... | @@ -498,10 +508,10 @@ export default { | ... | @@ -498,10 +508,10 @@ export default { |
| 498 | marker_icon = entity_info[i].icon; | 508 | marker_icon = entity_info[i].icon; |
| 499 | } | 509 | } |
| 500 | let text_direction = entity_info[i]?.writing_mode === 'vertical' ? 'vertical' : 'horizontal'; | 510 | let text_direction = entity_info[i]?.writing_mode === 'vertical' ? 'vertical' : 'horizontal'; |
| 501 | - | 511 | + |
| 502 | // 创建自定义HTML内容,包含图标和文字 | 512 | // 创建自定义HTML内容,包含图标和文字 |
| 503 | const markerContent = this.createMarkerContent(entity_info[i], text_direction, false); | 513 | const markerContent = this.createMarkerContent(entity_info[i], text_direction, false); |
| 504 | - | 514 | + |
| 505 | let textMarker = new AMap.Marker({ | 515 | let textMarker = new AMap.Marker({ |
| 506 | zooms: this.data_zooms, // 点标记显示的层级范围,使用地图配置的缩放范围 | 516 | zooms: this.data_zooms, // 点标记显示的层级范围,使用地图配置的缩放范围 |
| 507 | content: markerContent, // 自定义HTML内容 | 517 | content: markerContent, // 自定义HTML内容 |
| ... | @@ -526,7 +536,7 @@ export default { | ... | @@ -526,7 +536,7 @@ export default { |
| 526 | } | 536 | } |
| 527 | } | 537 | } |
| 528 | }); | 538 | }); |
| 529 | - | 539 | + |
| 530 | // 设置当前标记为选中状态 | 540 | // 设置当前标记为选中状态 |
| 531 | const newContent = this.createMarkerContent(entity_info[i], text_direction, true); | 541 | const newContent = this.createMarkerContent(entity_info[i], text_direction, true); |
| 532 | textMarker.setContent(newContent); | 542 | textMarker.setContent(newContent); | ... | ... |
-
Please register or login to post a comment