From ad5a7a527e7b0289a21f207f1859debd7e11033d Mon Sep 17 00:00:00 2001 From: Paul Adamsen <117673433+pauladamseniii@users.noreply.github.com> Date: Mon, 1 May 2023 11:36:10 -0400 Subject: [PATCH] CEC-3933 - Ensure zoom to car on Vehicle Map load (#326) * CEC-3933 - Parse VehiclePaths location data * changes * fixes * stuff * sort of works * fix * progress * refactor * fix vehicle paths query * digital twin shows map * new dashboard * wider digital twin map * snapshot * latest; using polylines * lag lng changes * stuff * path showing up * stuff * things * revert home page * whitespace * validation * more stuff * fix button issue * tests pass without mocking data * fix code smells * remove map from digital twin, add to tab * fix bug * marker click event working * individual colors * possible fix * fix warning * merge and remove unused code * small fixes * re add dashboard * snaps * CEC-3933 - Ensure zoom to car on Vehicle Map load --- .../Contexts/__mocks__/VehicleContext.jsx | 1 + src/components/VehiclePathsMap/index.jsx | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/components/Contexts/__mocks__/VehicleContext.jsx b/src/components/Contexts/__mocks__/VehicleContext.jsx index 3c76ba1..31e4283 100644 --- a/src/components/Contexts/__mocks__/VehicleContext.jsx +++ b/src/components/Contexts/__mocks__/VehicleContext.jsx @@ -137,6 +137,7 @@ export const useVehicleContext = () => ({ .fn() .mockResolvedValue({ // tests only pass without mocking the data here + // '3FAFP13P71R199267': [], // '3FAFP13P31R199430': [[16.891136999999986, 26.832352999999955], [56.891136999999986, 66.832352999999955], [26.891136999999986, 36.832352999999955]], // '3FAFP13P71R199060': [[36.891136999999986, 46.832352999999955], [76.891136999999986, 16.832352999999955]], }), diff --git a/src/components/VehiclePathsMap/index.jsx b/src/components/VehiclePathsMap/index.jsx index 97f7961..62449ee 100644 --- a/src/components/VehiclePathsMap/index.jsx +++ b/src/components/VehiclePathsMap/index.jsx @@ -60,15 +60,18 @@ const ComponentVehiclePathsMap = (props) => { // validate each location for (let vinLocations of resultArray) { - let path = [] - path[0] = vinLocations[0] - path[1] = [] - for (let location of vinLocations[1]) { - if (ValidateLocationVehiclePathsData(location) !== false) { - path[1].push(location); + // if there are points for the vin; skip if empty points array + if (vinLocations[0] && vinLocations[1] && vinLocations[1][0]) { + let path = [] + path[0] = vinLocations[0] + path[1] = [] + for (let location of vinLocations[1]) { + if (ValidateLocationVehiclePathsData(location) !== false) { + path[1].push(location); + } } + points.push(path) } - points.push(path) } setMarkers(points);