Explorar el Código

feat: 修改轮船当前位置角度错误bug

zhouyuhao hace 11 meses
padre
commit
1e722db62d

+ 8 - 6
src/views/Tracking/src/components/TrackingDetail/src/components/MapView.vue

@@ -324,7 +324,7 @@ const addShipMarker = (x: number) => {
       html: `
         <div class="container">
           <div class="circle"></div>
-          <span style="color:white;border:1px solid white" class="font_family icon-icon_path_b"></span>
+          <span style="color:white;border:1px solid white" class="font_family icon-icon_ocean_b"></span>
         </div>
         `,
       className: 'arrow-icon',
@@ -346,16 +346,18 @@ const addShipMarker = (x: number) => {
     const secondLastPoint = solidLine[solidLine.length - 2]
     // 计算线段末端的角度(以弧度为单位)
     const angle =
-      Math.atan2(
-        Number(lastPoint.lon) - Number(secondLastPoint.lon),
-        Number(lastPoint.lat) - Number(secondLastPoint.lat)
+      (Math.atan2(
+        Number(lastPoint.lat) - Number(secondLastPoint.lat), // Δlat (y)
+        Number(lastPoint.lon) - Number(secondLastPoint.lon) // Δlon (x)
       ) *
-      (180 / Math.PI)
+        (180 / Math.PI) +
+        360) %
+      360
 
     // 创建自定义箭头图标
     const arrowIcon = L.divIcon({
       html: `
-      <div style="transform: rotate(${90 - angle}deg);" class="container">
+      <div style="transform: rotate(${angle}deg);" class="container">
         <div class="circle"></div>
         <span style="color:white;border:1px solid white" class="font_family icon-icon_arrow_b"></span>
       </div>