Merge pull request #2 from rozbehk/development

fix for map first load
This commit is contained in:
rozbehk 2025-10-06 14:44:43 -04:00 committed by GitHub
commit 1cffd1f4c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -125,6 +125,23 @@ const FlightsLayer = ({ flightsData, updateInterval = 5000 }) => {
return null; return null;
}; };
const InitialBounds = ({ setBoundries }) => {
const map = useMap();
useEffect(() => {
// Wait for map to be ready, then set initial bounds
map.whenReady(() => {
const bounds = map.getBounds();
setBoundries({
southWest: bounds.getSouthWest(),
northEast: bounds.getNorthEast(),
});
});
}, [map, setBoundries]);
return null;
};
const createPlaneIcon = (heading = 0) => { const createPlaneIcon = (heading = 0) => {
const html = ` const html = `
<div style=" <div style="
@ -220,6 +237,7 @@ const MapView = () => {
worldCopyJump={true} worldCopyJump={true}
> >
<TileLayer url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" /> <TileLayer url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" />
<InitialBounds setBoundries={setBoundaries} />
<FlightsLayer flightsData={flights} updateInterval={2000} /> <FlightsLayer flightsData={flights} updateInterval={2000} />
<MapBounds setBoundries={setBoundaries} /> <MapBounds setBoundries={setBoundaries} />
</MapContainer> </MapContainer>