perf(monitor): synchronize map follow frames

This commit is contained in:
lingniu
2026-07-16 10:32:31 +08:00
parent 77f12be63e
commit cf9e2a9803
2 changed files with 11 additions and 4 deletions

View File

@@ -524,7 +524,10 @@ export function FleetMap({ vehicles, selectedVin, onSelect, monitorMap, onSelect
const label = labelMarkersRef.current.get(motion.point.id);
label?.marker.setPosition?.(motion.point.lnglat);
if (label) label.position = motion.point.lnglat;
if (selectedVinRef.current === motion.point.id) selectionRef.current?.setPosition?.(motion.point.lnglat);
if (selectedVinRef.current === motion.point.id) {
selectionRef.current?.setPosition?.(motion.point.lnglat);
if (followSelectedRef.current) mapRef.current?.setCenter?.(motion.point.lnglat);
}
}
};
const schedule = () => {
@@ -653,8 +656,8 @@ export function FleetMap({ vehicles, selectedVin, onSelect, monitorMap, onSelect
if (currentZoom < 15) mapRef.current.setZoomAndCenter?.(15, mapPosition);
else mapRef.current.panTo?.(mapPosition, MAP_INTERACTION_PAN_DURATION_MS);
centeredVinRef.current = selectedVin;
} else if (selectionPositionRef.current && selectionPositionRef.current !== positionKey && followSelectedRef.current) {
mapRef.current.panTo?.(mapPosition, pointMoveDurationMs(target.reportIntervalMs));
} else if (selectionPositionRef.current && selectionPositionRef.current !== positionKey && followSelectedRef.current && !movingPointIDsRef.current.has(selectedVin)) {
mapRef.current.panTo?.(mapPosition, MAP_INTERACTION_PAN_DURATION_MS);
}
const previousPositionKey = selectionPositionRef.current;
selectionPositionRef.current = positionKey;