hookehuyr

fix 上传图片比例问题,加了系数调整。

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-08 17:48:34 4 + * @LastEditTime: 2025-02-20 16:10:07
5 * @FilePath: /map-demo/src/views/mapCutter.vue 5 * @FilePath: /map-demo/src/views/mapCutter.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -146,7 +146,7 @@ const zoom_options = [ ...@@ -146,7 +146,7 @@ const zoom_options = [
146 const map_left_bottom_range = ref(null); // 120.583625,31.311858 146 const map_left_bottom_range = ref(null); // 120.583625,31.311858
147 const map_right_top_range = ref(null); // 120.591047,31.318265 147 const map_right_top_range = ref(null); // 120.591047,31.318265
148 148
149 -const map_center = ref([120.587648, 31.314616]); 149 +const map_center = ref([117.13291,26.873757]);
150 150
151 const log_lnglat = ref('') // 获取当前地址经纬度 151 const log_lnglat = ref('') // 获取当前地址经纬度
152 152
...@@ -282,7 +282,7 @@ async function addImageToMap(url) { ...@@ -282,7 +282,7 @@ async function addImageToMap(url) {
282 282
283 const imgWidth = img.width; 283 const imgWidth = img.width;
284 const imgHeight = img.height; 284 const imgHeight = img.height;
285 - const aspectRatio = imgWidth / imgHeight; // 图片宽高比 285 + const aspectRatio = Number((imgWidth / imgHeight).toFixed(3)); // 图片宽高比
286 286
287 // 获取左下角经纬度 287 // 获取左下角经纬度
288 const [lng1, lat1] = map_left_bottom_range.value; 288 const [lng1, lat1] = map_left_bottom_range.value;
...@@ -301,7 +301,7 @@ async function addImageToMap(url) { ...@@ -301,7 +301,7 @@ async function addImageToMap(url) {
301 if (mapLngWidth / mapLatHeight > aspectRatio) { 301 if (mapLngWidth / mapLatHeight > aspectRatio) {
302 // 地图太宽了,需要基于高度调整宽度 302 // 地图太宽了,需要基于高度调整宽度
303 const latHeight = mapLatHeight * img_ratio.value; // 设定图片占地图的比例(可以调整) 303 const latHeight = mapLatHeight * img_ratio.value; // 设定图片占地图的比例(可以调整)
304 - const lngWidth = latHeight * aspectRatio; 304 + const lngWidth = latHeight * (aspectRatio + 0.2);
305 305
306 lat2 = lat1 + latHeight; 306 lat2 = lat1 + latHeight;
307 lng2 = lng1 + lngWidth; 307 lng2 = lng1 + lngWidth;
......