(null);
if (!API_KEY) {
return (
Set NEXT_PUBLIC_GOOGLE_MAPS_API_KEY in .env to enable the map.
);
}
// A point can be re-fetched (new object identity) between renders; keep the
// InfoWindow anchored to the latest copy of the same point by id. The
// liveStatus marker's "point" is synthesized fresh from liveStatus each
// time — but only for the id it actually owns. Other callers (e.g. the
// devices page's single current-position point) may also use a "live-"
// prefixed id without ever passing a liveStatus prop, so that id alone
// can't be used to decide which source to read from.
const selectedCurrent = (() => {
if (!selected) {
return null;
}
if (liveStatus && selected.id === `live-${liveStatus.deviceId}`) {
return liveStatusToMapPoint(liveStatus);
}
return points.find((p) => p.id === selected.id) ?? selected;
})();
return (
setSelected(null)}
>
{selectedCurrent && setSelected(null)} />}
);
}