فهرست منبع

修改单船定位,增加显示隐藏参数

sbj 1 سال پیش
والد
کامیت
b266103b45
1فایلهای تغییر یافته به همراه30 افزوده شده و 24 حذف شده
  1. 30 24
      src/utils/map/Boat.js

+ 30 - 24
src/utils/map/Boat.js

@@ -12,33 +12,39 @@ let boatInterval;
 let showBoat = false;
 
 // 船舶定位
-export function locationBoat(mmsi){
-    GetHpjShip().then(res=>{
-        let data = res.Result.data
-        let boats = {
-            "scale": 2000,
-            "goto": true,
-            "data": []
-        }
-        for(let i=0;i<data.length;i++){
-            if(data[i].DEVICEID == mmsi){
-                let boat = {
-                    "mmsi": data[i].DEVICEID,
-                    "shipNameCn": data[i].BOATNAME,
-                    "shipTypeName": data[i].SHIPTYPENAME,
-                    "direction": data[i].DIRECTION,
-                    "velocity": data[i].VELOCITY,
-                    "shipBreadth": data[i].SHIPBREADTH,
-                    "shipLength": data[i].SHIPLENGTH,
-                    "mapx": data[i].MAPX,
-                    "mapy": data[i].MAPY
+export function locationBoat(mmsi,isShow){
+    if(isShow){
+        GetHpjShip().then(res=>{
+            let data = res.Result.data
+            let boats = {
+                "scale": 2000,
+                "goto": true,
+                "data": []
+            }
+            for(let i=0;i<data.length;i++){
+                if(data[i].DEVICEID == mmsi){
+                    let boat = {
+                        "mmsi": data[i].DEVICEID,
+                        "shipNameCn": data[i].BOATNAME,
+                        "shipTypeName": data[i].SHIPTYPENAME,
+                        "direction": data[i].DIRECTION,
+                        "velocity": data[i].VELOCITY,
+                        "shipBreadth": data[i].SHIPBREADTH,
+                        "shipLength": data[i].SHIPLENGTH,
+                        "mapx": data[i].MAPX,
+                        "mapy": data[i].MAPY
+                    }
+                    boats.data.push(boat)
                 }
-                boats.data.push(boat)
             }
+            // console.log('定位:'+JSON.stringify(boats))
+            addBoats(boats)
+        })
+    }else{
+        if (!showBoat){
+            clearMap({is_draw: false, is_search:false, layers: ['boatLayer']})
         }
-        // console.log('定位:'+JSON.stringify(boats))
-        addBoats(boats)
-    })
+    }
 }
 
 // 船舶撒点