通过判断机型,优化路线和车辆mark的显示不连贯,中间有空隙的问题。
| | |
| | | } |
| | | |
| | | const executeRouteErase = () => { |
| | | if (bestMatchIndex >= startIndex && bestDistance < ROUTE_ERASE_MAX_DISTANCE_METERS) { |
| | | Taro.createMapContext('map').eraseLines({ |
| | | lines: [{ |
| | | id: ROUTE_POLYLINE_BASE_ID, |
| | | index: Math.max(0, bestMatchIndex - 1), |
| | | point: { |
| | | latitude: boundaryPoint.latitude, |
| | | longitude: boundaryPoint.longitude, |
| | | }, |
| | | clear: true |
| | | }] |
| | | }); |
| | | } |
| | | applyErasedRoutePoints(newPoints); |
| | | }; |
| | | if (bestMatchIndex >= startIndex && bestDistance < ROUTE_ERASE_MAX_DISTANCE_METERS) { |
| | | // [BugFix] 获取当前真实激活的主路线 ID,防止多路线(修改目的地)态下擦线 ID 不匹配导致静默失效 |
| | | const activePolylineId = deps.shouldShowRoute && deps.allowSelectableRoutes && allRoutePoints.length > 1 |
| | | ? ROUTE_POLYLINE_BASE_ID + selectedRouteIndex |
| | | : ROUTE_POLYLINE_BASE_ID; |
| | | Taro.createMapContext('map').eraseLines({ |
| | | lines: [{ |
| | | id: activePolylineId, |
| | | // [BugFix] 修复 Android 端 eraseLines Bug: Android 有时会连带 point 所在的整段 index 全部擦除导致视觉断层。 |
| | | // 针对 Android 平台强制 index 减 1,做保守补偿擦除,使车辆能完美贴合断点。 |
| | | index: deps.isAndroid ? Math.max(0, bestMatchIndex - 1) : bestMatchIndex, |
| | | point: { |
| | | latitude: boundaryPoint.latitude, |
| | | longitude: boundaryPoint.longitude, |
| | | }, |
| | | clear: true |
| | | }] |
| | | }); |
| | | } |
| | | applyErasedRoutePoints(newPoints); |
| | | }; |
| | | |
| | | if (process.env.TARO_ENV !== 'weapp' || routeEraseReadyRef.current) { |
| | | executeRouteErase(); |
| | |
| | | updateVehicleLocationThrottled: (lat: number, lng: number, force?: boolean) => void; |
| | | /** 读取用户手势是否进行中(拖拽/缩放手势 begin→end 之间为 true)。 */ |
| | | getUserGestureActive?: () => boolean; |
| | | /** 是否为安卓设备 */ |
| | | isAndroid: boolean; |
| | | /** 当前激活的主路线折线 ID */ |
| | | activePolylineId: number; |
| | | }; |
| | | |
| | | type MotionRuntimeState = { |
| | |
| | | PROJECT_SOFT_THRESHOLD_METERS = 25, |
| | | } |
| | | |
| | | const ROUTE_POLYLINE_ID = 2001; // 主路线折线 id |
| | | const FIRST_ROUTE_ERASE_READY_DELAY_MS = 120; |
| | | |
| | | export default function useSmoothRouteMotion(deps: Deps) { |
| | |
| | | const { index, point } = getRouteCursorByDistance(routeIndex, nextDistance); |
| | | Taro.createMapContext('map').eraseLines({ |
| | | lines: [{ |
| | | id: ROUTE_POLYLINE_ID, |
| | | index, |
| | | id: deps.activePolylineId, |
| | | // [BugFix] 修复 Android 端 eraseLines Bug: Android 有时会连带 point 所在的整段 index 全部擦除导致车辆和路线之间出现“空距离”的视觉断层。 |
| | | // 针对 Android 平台强制 index 减 1 做保守补偿擦除。 |
| | | index: deps.isAndroid ? Math.max(0, index - 1) : index, |
| | | point, |
| | | clear: true, |
| | | }] |
| | |
| | | import useAndroidOverlays from './hooks/use-android-overlays'; |
| | | import useRouteSummaryAnchorLocation from './hooks/use-route-summary-anchor-location'; |
| | | // 地图视口状态管理 |
| | | import { ROUTE_POLYLINE_BASE_ID } from './hooks/use-route-manager.shared'; |
| | | import useMapViewport from './hooks/use-map-viewport'; |
| | | import useActiveTripScale from './hooks/use-active-trip-scale'; |
| | | // 速度驱动的地图自动缩放 |
| | |
| | | setVehicleDirection, |
| | | setVehicleMoveAlongPoints, |
| | | updateVehicleLocationThrottled: vehicleState.updateVehicleLocationThrottled, |
| | | getUserGestureActive: () => userGestureActiveRef.current |
| | | getUserGestureActive: () => userGestureActiveRef.current, |
| | | isAndroid, |
| | | activePolylineId: allowSelectableRoutes && routeState.allRoutePoints.length > 1 |
| | | ? ROUTE_POLYLINE_BASE_ID + routeState.selectedRouteIndex |
| | | : ROUTE_POLYLINE_BASE_ID |
| | | }); |
| | | |
| | | useEffect(() => { |
| | |
| | | Taro.createMapContext('map').eraseLines({ |
| | | lines: [{ |
| | | id: ROUTE_POLYLINE_BASE_ID, |
| | | index: Math.max(0, bestMatchIndex - 1), |
| | | // [BugFix] 修复 Android 端 eraseLines Bug: Android 有时会连带 point 所在的整段 index 全部擦除导致视觉断层。 |
| | | // 针对 Android 平台强制 index 减 1,做保守补偿擦除,使车辆能完美贴合断点。 |
| | | index: deps.isAndroid ? Math.max(0, bestMatchIndex - 1) : bestMatchIndex, |
| | | point: { |
| | | latitude: boundaryPoint.latitude, |
| | | longitude: boundaryPoint.longitude |
| | |
| | | toMeters, |
| | | type RouteIndex, |
| | | } from './trip-motion-utils'; |
| | | import { ROUTE_POLYLINE_BASE_ID } from './use-route-manager.shared'; |
| | | |
| | | type Deps = { |
| | | tripStatus: number; |
| | |
| | | setVehicleDirection: (value: number) => void; |
| | | setVehicleMoveAlongPoints: (points: RoutePoint[]) => void; |
| | | updateVehicleLocationThrottled: (lat: number, lng: number, force?: boolean) => void; |
| | | isAndroid: boolean; |
| | | }; |
| | | |
| | | type MotionRuntimeState = { |
| | |
| | | REBASE_ROUTE_DEVIATION_METERS = 30, |
| | | } |
| | | |
| | | const ROUTE_POLYLINE_ID = 2001; |
| | | const FIRST_ROUTE_ERASE_READY_DELAY_MS = 120; |
| | | |
| | | export default function useSmoothRouteMotion(deps: Deps) { |
| | |
| | | const { index, point } = getRouteCursorByDistance(routeIndex, nextDistance); |
| | | Taro.createMapContext('map').eraseLines({ |
| | | lines: [{ |
| | | id: ROUTE_POLYLINE_ID, |
| | | index, |
| | | id: ROUTE_POLYLINE_BASE_ID, |
| | | // [BugFix] 修复 Android 端 eraseLines Bug: Android 有时会连带 point 所在的整段 index 全部擦除导致车辆和路线之间出现“空距离”的视觉断层。 |
| | | // 针对 Android 平台强制 index 减 1 做保守补偿擦除。 |
| | | index: deps.isAndroid ? Math.max(0, index - 1) : index, |
| | | point, |
| | | clear: true, |
| | | }] |
| | |
| | | setVehicleDirection, |
| | | setVehicleMoveAlongPoints, |
| | | updateVehicleLocationThrottled, |
| | | isAndroid, |
| | | }); |
| | | |
| | | const { |