weird zoom bug
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { Typography } from "@material-ui/core";
|
||||
import useStyles from "../useStyles";
|
||||
import { MapContainer, TileLayer, Marker, Popup } from 'react-leaflet'
|
||||
|
||||
import { useUserContext } from "../Contexts/UserContext";
|
||||
import { useStatusContext } from "../Contexts/StatusContext";
|
||||
import { useVehicleContext, VehicleProvider } from "../Contexts/VehicleContext";
|
||||
import { parsePayload } from "../../utils/jwt";
|
||||
import { VehicleMap } from "../VehicleMap";
|
||||
import VehicleMap from "../VehicleMap";
|
||||
|
||||
const DEFAULT_GREETING = "Welcome";
|
||||
|
||||
@@ -22,44 +20,17 @@ const getGreeting = (token) => {
|
||||
return `Welcome ${payload.given_name}!`;
|
||||
};
|
||||
|
||||
const MainForm = () => {
|
||||
const Home = () => {
|
||||
const classes = useStyles();
|
||||
const { token } = useUserContext();
|
||||
const greeting = getGreeting(token);
|
||||
const { setTitle } = useStatusContext();
|
||||
const { getLocations } = useVehicleContext();
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
setTitle("");
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
const position = [37.76405462601394, -122.41375345900552];
|
||||
const [markers, setMarkers] = useState([]);
|
||||
|
||||
useEffect(() => {
|
||||
var now = new Date();
|
||||
var timeStart = Math.round(now.getTime() / 1000) - 60 * 60 * 24;
|
||||
|
||||
getLocations(token)
|
||||
.then((result) => console.log(result));
|
||||
|
||||
// var queryPath = `api/datasources/proxy/2/?query=SELECT%0A%20%20%20%20t1.timestamp%20as%20%22timestamp%22%2C%0A%20%20%20%20t1.vin%20as%20%22vin%22%2C%0A%20%20%20%20t1.value%20as%20%22lat%22%2C%0A%20%20%20%20t2.value%20as%20%22lon%22%2C%0A%20%20%20%20t3.value%20as%20%22alt%22%0AFROM%20default.vehicle_signal%20t1%0A%0AJOIN%20default.vehicle_signal%20t2%0A%20%0A%20ON%20%20t1.timestamp%3Dt2.timestamp%20AND%20t1.vin%3Dt2.vin%0A%0AJOIN%20default.vehicle_signal%20t3%0A%20%0A%20ON%20%20t1.timestamp%3Dt3.timestamp%20AND%20t1.vin%3Dt3.vin%0A%0AJOIN%0A(%0A%20%20%20%20SELECT%0A%20%20%20%20%20%20%20%20vin%2C%0A%20%20%20%20%20%20%20%20MAX(timestamp)%20as%20%22timestamp%22%0A%20%20%20%20FROM%20default.vehicle_signal%0A%0A%20%20%20%20GROUP%20BY%20vin%0A%0A)%20%20mostRecent%0A%20ON%20%20t1.timestamp%3DmostRecent.timestamp%20AND%20t1.vin%3DmostRecent.vin%0A%0AWHERE%0A%20%20%20%20toDateTime64(timestamp%2C%203)%20%3E%3D%20toDateTime64(${timeStart}%2C%203)%0A%20%20%20%20AND%20t1.name%20%3D%20'EHU_GPSLati'%0A%20%20%20%20AND%20t2.name%20%3D%20'EHU_GPSLongi'%0A%20%20%20%20AND%20t3.name%20%3D%20'EHU_GPSHei'%20FORMAT%20JSON`
|
||||
// var TIMEOUT = 10000
|
||||
|
||||
// const interval = setInterval(() => {
|
||||
// fetch(`https://grafana.fiskerdps.com/${queryPath}`)
|
||||
// .then(response => response.json())
|
||||
// .then(payload => {
|
||||
// console.log(payload.data)
|
||||
// setMarkers(payload.data.filter((coord) => [coord.lat, coord.lon]))
|
||||
// })
|
||||
// .then(() => console.log(markers));
|
||||
// console.log("hit interval");
|
||||
// }, TIMEOUT);
|
||||
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className={classes.paper}>
|
||||
<Typography component="h1" variant="h5">
|
||||
@@ -67,39 +38,9 @@ const MainForm = () => {
|
||||
</Typography>
|
||||
|
||||
<br />
|
||||
|
||||
<MapContainer
|
||||
center={position}
|
||||
zoom={13}
|
||||
style={{
|
||||
width: '100%',
|
||||
height: '900px'
|
||||
}}
|
||||
>
|
||||
<TileLayer
|
||||
attribution='© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
||||
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
||||
/>
|
||||
{
|
||||
markers.map((position) => {
|
||||
return (
|
||||
<Marker position={position}>
|
||||
<Popup>
|
||||
VIN123 <br /> Stat1 <br /> Stat2 <br /> Stat 3
|
||||
</Popup>
|
||||
</Marker>
|
||||
)
|
||||
})
|
||||
}
|
||||
</MapContainer>
|
||||
<VehicleMap />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const Home = () => (
|
||||
<VehicleProvider>
|
||||
<MainForm />
|
||||
</VehicleProvider>
|
||||
);
|
||||
|
||||
export default Home;
|
||||
|
||||
Reference in New Issue
Block a user