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() }) }