Showing
1 changed file
with
22 additions
and
2 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2025-01-22 11:40:12 | 2 | * @Date: 2025-01-22 11:40:12 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-02-26 09:54:08 | 4 | + * @LastEditTime: 2025-02-26 17:35:21 |
| 5 | * @FilePath: /map-demo/src/views/mapCutter.vue | 5 | * @FilePath: /map-demo/src/views/mapCutter.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -111,6 +111,12 @@ | ... | @@ -111,6 +111,12 @@ |
| 111 | <button class="z-button" @click="rotateMap(10)">↺</button> | 111 | <button class="z-button" @click="rotateMap(10)">↺</button> |
| 112 | <button class="z-button" @click="rotateMap(-10)">↻</button> | 112 | <button class="z-button" @click="rotateMap(-10)">↻</button> |
| 113 | </div> | 113 | </div> |
| 114 | + | ||
| 115 | + <!-- 透明度控制 --> | ||
| 116 | + <div class="opacity-control"> | ||
| 117 | + <div style="margin-bottom: 1rem;">透明度: {{ imageOpacity }}%</div> | ||
| 118 | + <van-slider v-model="imageOpacity" :min="0" :max="100" @change="handleOpacityChange" style="width: 200px;" /> | ||
| 119 | + </div> | ||
| 114 | </div> | 120 | </div> |
| 115 | </div> | 121 | </div> |
| 116 | </template> | 122 | </template> |
| ... | @@ -276,6 +282,14 @@ function handleImageUpload(event) { | ... | @@ -276,6 +282,14 @@ function handleImageUpload(event) { |
| 276 | event.target.value = ""; | 282 | event.target.value = ""; |
| 277 | } | 283 | } |
| 278 | 284 | ||
| 285 | +const imageOpacity = ref(60); // 默认透明度为60% | ||
| 286 | + | ||
| 287 | +const handleOpacityChange = (value) => { | ||
| 288 | + if (imageLayer.value) { | ||
| 289 | + imageLayer.value.setOpacity(value / 100); | ||
| 290 | + } | ||
| 291 | +}; | ||
| 292 | + | ||
| 279 | async function addImageToMap(url) { | 293 | async function addImageToMap(url) { |
| 280 | if (imageLayer.value) { | 294 | if (imageLayer.value) { |
| 281 | map.value.remove(imageLayer.value); | 295 | map.value.remove(imageLayer.value); |
| ... | @@ -332,7 +346,7 @@ async function addImageToMap(url) { | ... | @@ -332,7 +346,7 @@ async function addImageToMap(url) { |
| 332 | url: url, | 346 | url: url, |
| 333 | bounds: bounds.value, | 347 | bounds: bounds.value, |
| 334 | zooms: [17, 19], | 348 | zooms: [17, 19], |
| 335 | - opacity: 0.6 // 透明度 (0 完全透明, 1 完全不透明) | 349 | + opacity: imageOpacity.value / 100 // 使用响应式的透明度值 |
| 336 | }); | 350 | }); |
| 337 | 351 | ||
| 338 | map.value.add(imageLayer.value); | 352 | map.value.add(imageLayer.value); |
| ... | @@ -556,6 +570,12 @@ const onRatioBlur = () => { | ... | @@ -556,6 +570,12 @@ const onRatioBlur = () => { |
| 556 | border-radius: 10px; | 570 | border-radius: 10px; |
| 557 | } | 571 | } |
| 558 | 572 | ||
| 573 | +.opacity-control { | ||
| 574 | + background: #f0f0f0; | ||
| 575 | + padding: 1rem 0; | ||
| 576 | + text-align: center; | ||
| 577 | +} | ||
| 578 | + | ||
| 559 | .direction-control { | 579 | .direction-control { |
| 560 | display: flex; | 580 | display: flex; |
| 561 | flex-direction: column; | 581 | flex-direction: column; | ... | ... |
-
Please register or login to post a comment