Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions dash/src/app/dashboard/weather/map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ export function WeatherMap() {
}

setFrames(pathFrames.map((frame, i) => ({ time: frame.time, id: i })));

// maybe set loading of controls here

// intervalRef.current = setInterval(updateFrameVisibility, 1000);
};

useEffect(() => {
Expand All @@ -69,16 +65,17 @@ export function WeatherMap() {

if (!meeting) return;

const coords = await fetchCoords(`${meeting.country.name}, ${meeting.location} circuit`);
if (!coords) {
console.error("no coords found");
return;
}
const [coordsC, coordsA] = await Promise.all([
fetchCoords(`${meeting.country.name}, ${meeting.location} circuit`),
fetchCoords(`${meeting.country.name}, ${meeting.location} autodrome`),
]);

const coords = coordsC || coordsA;

const libMap = new maplibregl.Map({
container: mapContainerRef.current,
style: `https://api.maptiler.com/maps/dataviz-dark/style.json?key=${env.NEXT_PUBLIC_MAP_KEY}`,
center: [coords.lon, coords.lat],
center: coords ? [coords.lon, coords.lat] : undefined,
zoom: 10,
canvasContextAttributes: {
antialias: true,
Expand All @@ -88,7 +85,9 @@ export function WeatherMap() {
libMap.on("load", async () => {
setLoading(false);

new Marker().setLngLat([coords.lon, coords.lat]).addTo(libMap);
if (coords) {
new Marker().setLngLat([coords.lon, coords.lat]).addTo(libMap);
}

await handleMapLoad();
});
Expand Down