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-08 10:49:55 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
68883e93010385e9d3941037be0c8c49a6110389
68883e93
1 parent
b6f8fa0f
可以自定义上传图片的比例
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
3 deletions
components.d.ts
src/views/mapCutter.vue
components.d.ts
View file @
68883e9
...
...
@@ -15,6 +15,7 @@ declare module '@vue/runtime-core' {
ElButton
:
typeof
import
(
'element-plus/es'
)[
'ElButton'
]
ElInput
:
typeof
import
(
'element-plus/es'
)[
'ElInput'
]
ElOption
:
typeof
import
(
'element-plus/es'
)[
'ElOption'
]
ElProgress
:
typeof
import
(
'element-plus/es'
)[
'ElProgress'
]
ElSelect
:
typeof
import
(
'element-plus/es'
)[
'ElSelect'
]
Floor
:
typeof
import
(
'./src/components/Floor/index.vue'
)[
'default'
]
InfoPopup
:
typeof
import
(
'./src/components/InfoPopup.vue'
)[
'default'
]
...
...
src/views/mapCutter.vue
View file @
68883e9
<!--
* @Date: 2025-01-22 11:40:12
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-02-08 10:
05:50
* @LastEditTime: 2025-02-08 10:
47:47
* @FilePath: /map-demo/src/views/mapCutter.vue
* @Description: 文件描述
-->
...
...
@@ -43,6 +43,12 @@
placeholder="输入右上角的经纬度"
@blur="onRTRangeBlur"
/> -->
<div>上传图片比例: </div>
<el-input
v-model="img_ratio"
style="width: 240px"
placeholder="输入上传图片比例"
/>
</div>
<div v-if="showUpload">
<input type="file" @change="handleImageUpload" />
...
...
@@ -84,6 +90,7 @@ const mapRotation = ref(0); // 存储地图旋转角度
const zooms = ref([17, 19]);
const map_zoom = ref(17)
const img_ratio = ref(0.5); // 图片缩放比例
const zoom_options = [
{
...
...
@@ -203,14 +210,14 @@ async function addImageToMap(url) {
let lat2, lng2;
if (mapLngWidth / mapLatHeight > aspectRatio) {
// 地图太宽了,需要基于高度调整宽度
const latHeight = mapLatHeight *
0.5
; // 设定图片占地图的比例(可以调整)
const latHeight = mapLatHeight *
img_ratio.value
; // 设定图片占地图的比例(可以调整)
const lngWidth = latHeight * aspectRatio;
lat2 = lat1 + latHeight;
lng2 = lng1 + lngWidth;
} else {
// 地图太高了,需要基于宽度调整高度
const lngWidth = mapLngWidth *
0.5
; // 设定图片占地图的比例(可以调整)
const lngWidth = mapLngWidth *
img_ratio.value
; // 设定图片占地图的比例(可以调整)
const latHeight = lngWidth / aspectRatio;
lat2 = lat1 + latHeight;
...
...
Please
register
or
login
to post a comment