From 21e8e8573ff81107b30be6e7f1d45d44fe6194b7 Mon Sep 17 00:00:00 2001 From: wangxiang <1827945911@qq.com> Date: Wed, 1 Jun 2022 17:53:52 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=81=20=E4=BF=AE=E5=A4=8D=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E5=8A=A0=E8=BD=BD=E9=A1=B5=E9=9D=A2=E5=8D=A1=E6=AD=BB?= =?UTF-8?q?=E6=83=85=E5=86=B5,=E8=BF=9B=E4=B8=8D=E5=8E=BB=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kicc-ui/src/components/AMap/src/Amap.vue | 67 ++++++++++++------------ 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/kicc-ui/src/components/AMap/src/Amap.vue b/kicc-ui/src/components/AMap/src/Amap.vue index f796bca5..c710793f 100644 --- a/kicc-ui/src/components/AMap/src/Amap.vue +++ b/kicc-ui/src/components/AMap/src/Amap.vue @@ -29,7 +29,7 @@ /> - + item.id == value); if (smallHospitalMap) { - // 绘制20公里,园形矢量图,并且检测这个范围内是否有收样员 - map.remove(scanTakeSpecimenCircleRange); - // 扫描收样员园形范围 - scanTakeSpecimenCircleRange = new AMap.Circle({ - radius: 8000, - borderWeight: 3, - strokeColor: '#3600ff', - strokeOpacity: 0.2, - strokeWeight: 6, - fillOpacity: 0.4, - strokeStyle: 'dashed', - strokeDasharray: [8, 8], - fillColor: '#1791fc', - zIndex: 50 - }); - + map.remove(scanTakeSpecimenCircleRange || {}); scanTakeSpecimenCircleRange.setCenter([smallHospitalMap.lng, smallHospitalMap.lat]); map.add(scanTakeSpecimenCircleRange); map.setFitView([ scanTakeSpecimenCircleRange ]); - // 查找园圈内的收样员 - const gatherCircleRangeSpecimen = []; - for (let i = 0; i < smallHospitalMapList.length; ++i) { - const smallHospitalMap = smallHospitalMapList[i]; - const specimenLngLat = new AMap.LngLat(smallHospitalMap.lng, smallHospitalMap.lat); - if (scanTakeSpecimenCircleRange.contains(specimenLngLat)) { - console.log('查找到'); - } else { - console.log('没有查找到'); - } - } - - - - + const smallHospitalMarker = new AMap.Marker({ + position: [smallHospitalMap.lng, smallHospitalMap.lat], + }); + const smallHospitalPosition = smallHospitalMarker.getPosition(); + // 计算最优先收样员顺序 + const optimalSpecimen = specimenMapList.sort((firstEl, secondEl) => { + const marker1 = new AMap.Marker({ + position: [firstEl.lng, firstEl.lat], + }),marker2 = new AMap.Marker({ + position: [secondEl.lng, secondEl.lat], + }); + const position1 = marker1.getPosition(), + position2 = marker2.getPosition(); + return Math.round(smallHospitalPosition.distance(position1)) - Math.round(smallHospitalPosition.distance(position2)); + }); + mapState.takeSpecimenList = optimalSpecimen.map(item => ({ value: item.id, label: item.title })); } else { throw '查找不到发单点数据,请检查发单点!'; }