hookehuyr

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

<!--
* @Date: 2025-01-22 11:40:12
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-02-08 17:48:34
* @LastEditTime: 2025-02-20 16:10:07
* @FilePath: /map-demo/src/views/mapCutter.vue
* @Description: 文件描述
-->
......@@ -146,7 +146,7 @@ const zoom_options = [
const map_left_bottom_range = ref(null); // 120.583625,31.311858
const map_right_top_range = ref(null); // 120.591047,31.318265
const map_center = ref([120.587648, 31.314616]);
const map_center = ref([117.13291,26.873757]);
const log_lnglat = ref('') // 获取当前地址经纬度
......@@ -282,7 +282,7 @@ async function addImageToMap(url) {
const imgWidth = img.width;
const imgHeight = img.height;
const aspectRatio = imgWidth / imgHeight; // 图片宽高比
const aspectRatio = Number((imgWidth / imgHeight).toFixed(3)); // 图片宽高比
// 获取左下角经纬度
const [lng1, lat1] = map_left_bottom_range.value;
......@@ -301,7 +301,7 @@ async function addImageToMap(url) {
if (mapLngWidth / mapLatHeight > aspectRatio) {
// 地图太宽了,需要基于高度调整宽度
const latHeight = mapLatHeight * img_ratio.value; // 设定图片占地图的比例(可以调整)
const lngWidth = latHeight * aspectRatio;
const lngWidth = latHeight * (aspectRatio + 0.2);
lat2 = lat1 + latHeight;
lng2 = lng1 + lngWidth;
......