From aa24dc255a308e9d08d3d274b1a3ec1fbdec3d88 Mon Sep 17 00:00:00 2001 From: yaoyuhao Date: Tue, 20 Aug 2024 14:32:52 +0800 Subject: [PATCH] gx --- src/view/sy_map.vue | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/view/sy_map.vue b/src/view/sy_map.vue index 7c2e30b..ab2bec4 100644 --- a/src/view/sy_map.vue +++ b/src/view/sy_map.vue @@ -816,10 +816,8 @@ const getCssj = () => { var arrJWD = [[[]]]; var arr1; -var iii; //百度bd09墨卡托坐标转换百度bd09经纬度坐标 -const bd09 = async (x, y, index) => { - iii=index; +const bd09 = (x, y) => { var ggPoint = new BMapGL.Point(x, y); var pointArr = []; pointArr.push(ggPoint); @@ -829,11 +827,9 @@ const bd09 = async (x, y, index) => { arr1.push(e.points[0].lng); arr1.push(e.points[0].lat); console.log("arr1", arr1); - arr1.push(iii); arrJWD[0][0].push(arr1); }); }; - //开启编辑 const openEdit = () => { cs_choose_arr.value[0].enableEditing(); @@ -841,12 +837,21 @@ const openEdit = () => { }; //关闭编辑 -const closeEdit = () => { +const closeEdit = async () => { cs_choose_arr.value[0].disableEditing(); console.log(cs_choose_arr.value[0]); - cs_choose_arr.value[0].points.forEach((item, index) => { - bd09(item.lng, item.lat, index); - }); + for (const item of cs_choose_arr.value[0].points) { + if (item?.latLng) { + arr1 = []; + arr1.push(item?.latLng.lng); + arr1.push(item?.latLng.lat); + arrJWD[0][0].push(arr1); + } else { + bd09(item.lng, item.lat); + //延迟0.1秒,保证convertor.translate执行完 + await new Promise(resolve => setTimeout(resolve, 100)); + } + } console.log("arrJWD", arrJWD); }; //点击龙游县初始化