浏览代码

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

wangzhihui 4 年之前
父节点
当前提交
bd10bdcfbc
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      src/views/voyage/voyageDetail.vue

+ 6 - 2
src/views/voyage/voyageDetail.vue

@@ -301,16 +301,20 @@ export default {
       for (let i of medias.value) {
         previewSrcList.value.push(i.downloadUrl);
       }
-      setShipMarker();
+      initMap();
     }
     function initMap() {
       map.value = new AMap.Map("map-container", {
         zoom: 11, //级别
         center: [121.524761, 31.228721], //中心点坐标
       });
+      let { longitude, latitude } =
+        coordinates.value[coordinates.value.length - 1];
+      setShipMarker(longitude, latitude);
     }
 
     function setShipMarker(longitude = 121.524761, latitude = 31.228721) {
+      map.value.setCenter([longitude, latitude]);
       var marker = new AMap.Marker({
         position: new AMap.LngLat(longitude, latitude),
         // offset: new AMap.Pixel(-10, -10),
@@ -320,6 +324,7 @@ export default {
       });
       map.value.add(marker);
     }
+
     let disabledStatus = ref(true);
     let updateCache = {};
     function changeVoyageInfo() {
@@ -416,7 +421,6 @@ export default {
     }
 
     onMounted(() => {
-      initMap();
       getVoyageDetail();
     });
     return {