From 112d624753fe3403b91d961fab22c8e022bad4ee Mon Sep 17 00:00:00 2001 From: Vishal <321vishalds@gmail.com> Date: Fri, 21 Jun 2024 16:59:46 +0530 Subject: [PATCH] DriveMap: fixed high CPU usage during idling (#515) --- src/components/DriveMap/index.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/DriveMap/index.jsx b/src/components/DriveMap/index.jsx index 2e381149..7abcc0ac 100644 --- a/src/components/DriveMap/index.jsx +++ b/src/components/DriveMap/index.jsx @@ -36,6 +36,7 @@ class DriveMap extends Component { this.shouldFlyTo = false; this.isInteracting = false; this.isInteractingTimeout = null; + this.lastMapPos = [0, 0]; } componentDidMount() { @@ -99,7 +100,8 @@ class DriveMap extends Component { if (markerSource) { if (this.props.currentRoute && this.props.currentRoute.driveCoords) { const pos = this.posAtOffset(currentOffset()); - if (pos) { + if (pos && pos.some((coordinate, index) => coordinate != this.lastMapPos[index])) { + this.lastMapPos = pos; markerSource.setData({ type: 'Point', coordinates: pos,