CEC-4543 - Add location to digital twin map (#376)
This commit is contained in:
@@ -7,7 +7,7 @@ import useStyles from "../useStyles";
|
||||
import GrayMarkerIcon from "../../assets/gray-marker.png";
|
||||
import GreenMarkerIcon from "../../assets/green-marker.png";
|
||||
import { logger } from "../../services/monitoring";
|
||||
import { ValidateLocationVehiclePathsData } from "../../utils/locations";
|
||||
import { ValidateLocationData, ValidateLocationVehiclePathsData } from "../../utils/locations";
|
||||
import { useUserContext } from "../Contexts/UserContext";
|
||||
import { useVehicleContext, VehicleProvider } from "../Contexts/VehicleContext";
|
||||
import { VehiclePopUp } from "../VehicleMap/popup";
|
||||
@@ -54,23 +54,32 @@ const ComponentVehiclePathsMap = (props) => {
|
||||
vinsParam += props.lookbackHours
|
||||
|
||||
return getLocationsVehiclePaths(accessToken, vinsParam)
|
||||
.then((result) => {
|
||||
.then(async (result) => {
|
||||
let resultArray = Object.entries(result)
|
||||
const points = []
|
||||
|
||||
// validate each location
|
||||
for (let vinLocations of resultArray) {
|
||||
// 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);
|
||||
if (vinLocations[0]) {
|
||||
let path = [];
|
||||
path[0] = vinLocations[0];
|
||||
path[1] = [];
|
||||
if (vinLocations[1] && vinLocations[1][0]) {
|
||||
for (let location of vinLocations[1]) {
|
||||
if (ValidateLocationVehiclePathsData(location) !== false) {
|
||||
path[1].push(location);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
await getState(token, vinLocations[0]).then((stateResult) => {
|
||||
if (stateResult.data && stateResult.data.location) {
|
||||
if (ValidateLocationData(stateResult.data.location) !== false) {
|
||||
path[1].push([stateResult.data.location.latitude, stateResult.data.location.longitude]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
points.push(path)
|
||||
points.push(path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user