Explorar el Código

更新 船舶定位/地图中心点

wangzhihui hace 4 años
padre
commit
b17fbae49f
Se han modificado 1 ficheros con 7 adiciones y 3 borrados
  1. 7 3
      src/views/voyage/voyageDetail.vue

+ 7 - 3
src/views/voyage/voyageDetail.vue

@@ -315,6 +315,7 @@ import router from "../../router";
 import store from "../../store";
 import store from "../../store";
 import { ElNotification } from "element-plus";
 import { ElNotification } from "element-plus";
 import PicTimelineVue from "../../components/PicTimeline.vue";
 import PicTimelineVue from "../../components/PicTimeline.vue";
+import { v } from "../../../dist/assets/vendor.f273df9f";
 
 
 export default {
 export default {
   components: {
   components: {
@@ -341,18 +342,21 @@ export default {
       for (let i of media.value) {
       for (let i of media.value) {
         previewSrcList.value.push(i.downloadUrl);
         previewSrcList.value.push(i.downloadUrl);
       }
       }
-      initMap(coordinates.value[0].longitude, coordinates.value[0].latitude);
+      initMap();
     }
     }
 
 
-    function initMap(longitude = 121.524761, latitude = 31.228721) {
+    function initMap() {
       map.value = new AMap.Map("map-container", {
       map.value = new AMap.Map("map-container", {
         zoom: 11, //级别
         zoom: 11, //级别
-        center: [longitude, latitude], //中心点坐标
+        center: [121.524761, 31.228721], //中心点坐标
       });
       });
+      let { longitude, latitude } =
+        coordinates.value[coordinates.value.length - 1];
       setShipMarker(longitude, latitude);
       setShipMarker(longitude, latitude);
     }
     }
 
 
     function setShipMarker(longitude = 121.524761, latitude = 31.228721) {
     function setShipMarker(longitude = 121.524761, latitude = 31.228721) {
+      map.value.setCenter([longitude, latitude]);
       var marker = new AMap.Marker({
       var marker = new AMap.Marker({
         position: new AMap.LngLat(longitude, latitude),
         position: new AMap.LngLat(longitude, latitude),
         // offset: new AMap.Pixel(-10, -10),
         // offset: new AMap.Pixel(-10, -10),