hookehuyr

fix 工具地图新增复制坐标功能

<!--
* @Date: 2023-05-19 14:54:27
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-08-07 09:54:06
* @LastEditTime: 2024-09-20 11:23:33
* @FilePath: /map-demo/src/views/tools.vue
* @Description: 公众地图主体页面
-->
......@@ -18,8 +18,8 @@
<van-button @click="setRotationPlus()" type="default" block size="small" style="width: 10rem; margin-left: 1rem;">旋转+10</van-button>
&nbsp;设置<van-field v-model="data_rotation" label="" placeholder="请输入旋转值" style="width: 3.5rem;" @blur="setRotation()" />度
</div>
<div v-if="log_lnglat" style="position: fixed; top: 5rem; left: 1rem; color: black;">
<div style="display: flex;">点击经纬度:{{ log_lnglat }}</div>
<div v-if="log_lnglat" style="position: fixed; top: 5rem; left: 1rem; color: black; background-color: white; padding: 1rem;">
<div style=" display: flex; align-items: center; justify-content: center;">经纬度:{{ log_lnglat }}&nbsp;&nbsp;&nbsp;<van-button @click="copyText(log_lnglat)" type="primary" icon="brush-o" size="small">复制</van-button></div>
</div>
<!-- <div class="nav-bar-wrapper">
<div class="hideScrollBar nav-bar-content">
......@@ -125,6 +125,7 @@ import audioBackground from '@/components/audioBackground'
import { useRect } from '@vant/use';
import { mapAPI } from '@/api/map.js'
import wx from 'weixin-js-sdk'
import { showToast } from 'vant';
const GPS = {
PI: 3.14159265358979324,
......@@ -955,7 +956,7 @@ export default {
e.lnglat.getLng() +
"," +
e.lnglat.getLat() +
"],"
"]"
console.log(text);
this.log_lnglat = text;
// 点击空白处 关闭弹框
......@@ -1225,7 +1226,17 @@ export default {
},
setRotation () {
this.map.setRotation(+this.data_rotation);
}
},
copyText (text) {
navigator.clipboard.writeText(text)
.then(() => {
showToast('复制成功');
})
.catch(err => {
showToast('复制失败');
console.error('复制失败:', err);
});
},
}
}
</script>
......