瀏覽代碼

feat: 为干线协调和勤务路线的圆点添加起点终点标识

sequoia tungfang 3 周之前
父節點
當前提交
5170610cea
共有 1 個文件被更改,包括 15 次插入5 次删除
  1. 15 5
      src/components/TongzhouTrafficMap.vue

+ 15 - 5
src/components/TongzhouTrafficMap.vue

@@ -478,17 +478,27 @@ export default {
         const totalPoints = segmentPath.length;
         const indices = this.pickEvenlySpacedIndices(totalPoints, 8);
 
-        for (const i of indices) {
-          const p = segmentPath[i];
+        // 为第一个和最后一个圆点设置特殊类型
+        for (let i = 0; i < indices.length; i++) {
+          const idx = indices[i];
+          const p = segmentPath[idx];
           const lng = p && typeof p.lng === 'number' ? p.lng : (Array.isArray(p) ? Number(p[0]) : NaN);
           const lat = p && typeof p.lat === 'number' ? p.lat : (Array.isArray(p) ? Number(p[1]) : NaN);
           if (Number.isNaN(lng) || Number.isNaN(lat)) continue;
 
+          // 确定圆点类型:第一个为start,最后一个为end,其余为normal
+          let markerType = 'normal';
+          if (i === 0) {
+            markerType = 'start';
+          } else if (i === indices.length - 1) {
+            markerType = 'end';
+          }
+
           const marker = this.createTrafficLightMarker([lng, lat], {
             ...config,
-            id: `MOCK-${configName.charAt(0)}-${lineIdx}-${segmentIdx}-${i}`,
-            road: `${configName}路口-${lineIdx}-${segmentIdx}-${i}`
-          });
+            id: `MOCK-${configName.charAt(0)}-${lineIdx}-${segmentIdx}-${idx}`,
+            road: `${configName}路口-${lineIdx}-${segmentIdx}-${idx}`
+          }, markerType);
           if (marker) overlays.push(marker);
         }
       });