Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
map-demo
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2025-02-26 17:40:04 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
28ab28186178c224ea7ac86d1a91a9f51ea8aae1
28ab2818
1 parent
9a4d805e
fix 新增图片透明度调整
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
2 deletions
src/views/mapCutter.vue
src/views/mapCutter.vue
View file @
28ab281
<!--
* @Date: 2025-01-22 11:40:12
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-02-26
09:54:08
* @LastEditTime: 2025-02-26
17:35:21
* @FilePath: /map-demo/src/views/mapCutter.vue
* @Description: 文件描述
-->
...
...
@@ -111,6 +111,12 @@
<button class="z-button" @click="rotateMap(10)">↺</button>
<button class="z-button" @click="rotateMap(-10)">↻</button>
</div>
<!-- 透明度控制 -->
<div class="opacity-control">
<div style="margin-bottom: 1rem;">透明度: {{ imageOpacity }}%</div>
<van-slider v-model="imageOpacity" :min="0" :max="100" @change="handleOpacityChange" style="width: 200px;" />
</div>
</div>
</div>
</template>
...
...
@@ -276,6 +282,14 @@ function handleImageUpload(event) {
event.target.value = "";
}
const imageOpacity = ref(60); // 默认透明度为60%
const handleOpacityChange = (value) => {
if (imageLayer.value) {
imageLayer.value.setOpacity(value / 100);
}
};
async function addImageToMap(url) {
if (imageLayer.value) {
map.value.remove(imageLayer.value);
...
...
@@ -332,7 +346,7 @@ async function addImageToMap(url) {
url: url,
bounds: bounds.value,
zooms: [17, 19],
opacity:
0.6 // 透明度 (0 完全透明, 1 完全不透明)
opacity:
imageOpacity.value / 100 // 使用响应式的透明度值
});
map.value.add(imageLayer.value);
...
...
@@ -556,6 +570,12 @@ const onRatioBlur = () => {
border-radius: 10px;
}
.opacity-control {
background: #f0f0f0;
padding: 1rem 0;
text-align: center;
}
.direction-control {
display: flex;
flex-direction: column;
...
...
Please
register
or
login
to post a comment