From 7496c9bb3788bee870118f51a71d32a0deacfcba Mon Sep 17 00:00:00 2001 From: Shikong <919411476@qq.com> Date: Thu, 16 Mar 2023 18:31:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=80=A7=E8=83=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/record/AMapLocation.vue | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/frontend/matrix-middle-service-web/src/views/record/AMapLocation.vue b/frontend/matrix-middle-service-web/src/views/record/AMapLocation.vue index c73faea..9bbb322 100644 --- a/frontend/matrix-middle-service-web/src/views/record/AMapLocation.vue +++ b/frontend/matrix-middle-service-web/src/views/record/AMapLocation.vue @@ -149,6 +149,17 @@ AMapLoader.load({ zoom: 14, }); console.log("地图对象", map) + map.on("moveend",()=>{ + let bounds = map.getBounds() + data.markers.forEach(marker=>{ + if(bounds.contains(marker.getPosition())) { + marker.show() + } else { + marker.hide() + } + }) + }) + map.addControl(scale) map.addControl(toolBar) map.addControl(controlBar) @@ -281,6 +292,7 @@ function search() { return marker; }) + data.markers = markers labelsLayer.add(markers) map.add(data.labelsLayer) @@ -320,11 +332,6 @@ function search() { data.polylines.push(polyline) }) console.log("polylines",data.polylines) - - if (data.polylines.length > 0) { - map.panTo(data.polylines[0].getPath()[0]) - map.setFitView() - } // polyline = new AMap.Polyline({ // path: path, // showDir: true, @@ -336,7 +343,11 @@ function search() { // lineJoin: 'round' // 折线拐点连接处样式}) // }) map.add(data.polylines) - + setTimeout(()=>{ + if (data.polylines.length > 0) { + map.setFitView() + } + }) fixedLocation() }) }