|
|
@@ -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);
|
|
|
}
|
|
|
});
|