Fix jwt-token
This commit is contained in:
@@ -183,42 +183,20 @@ const MapView = () => {
|
|||||||
console.log('MapView: fetchDevices - Device data received, length:', deviceData.length);
|
console.log('MapView: fetchDevices - Device data received, length:', deviceData.length);
|
||||||
setDevices(deviceData);
|
setDevices(deviceData);
|
||||||
|
|
||||||
// Calculate bounds dynamically based on device locations
|
// Just log device bounds for reference, but don't use them
|
||||||
if (deviceData.length > 0) {
|
if (deviceData.length > 0) {
|
||||||
const lats = deviceData.map(device => device.geo_lat);
|
const lats = deviceData.map(device => device.geo_lat);
|
||||||
const lons = deviceData.map(device => device.geo_lon);
|
const lons = deviceData.map(device => device.geo_lon);
|
||||||
|
|
||||||
const minLat = Math.min(...lats);
|
const minLat = Math.min(...lats);
|
||||||
const maxLat = Math.max(...lats);
|
const maxLat = Math.max(...lats);
|
||||||
const minLon = Math.min(...lons);
|
const minLon = Math.min(...lons);
|
||||||
const maxLon = Math.max(...lons);
|
const maxLon = Math.max(...lons);
|
||||||
|
console.log('MapView: Device bounds (info only):', { minLat, maxLat, minLon, maxLon });
|
||||||
// Add padding around the bounds (10% on each side)
|
|
||||||
const latPadding = (maxLat - minLat) * 0.1;
|
|
||||||
const lonPadding = (maxLon - minLon) * 0.1;
|
|
||||||
|
|
||||||
const bounds = [
|
|
||||||
[minLat - latPadding, minLon - lonPadding], // Southwest
|
|
||||||
[maxLat + latPadding, maxLon + lonPadding] // Northeast
|
|
||||||
];
|
|
||||||
|
|
||||||
// Only set bounds and center on initial load, not on periodic refreshes
|
|
||||||
if (isInitialLoad) {
|
|
||||||
setMapBounds(bounds);
|
|
||||||
setShouldFitBounds(true);
|
|
||||||
const centerLat = (minLat + maxLat) / 2;
|
|
||||||
const centerLon = (minLon + maxLon) / 2;
|
|
||||||
setMapCenter([centerLat, centerLon]);
|
|
||||||
|
|
||||||
// Disable bounds fitting after a short delay to allow initial fit
|
|
||||||
setTimeout(() => {
|
|
||||||
setShouldFitBounds(false);
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always mark initial load as complete after first fetch, regardless of device data
|
// Always mark initial load as complete after first fetch
|
||||||
if (isInitialLoad) {
|
if (isInitialLoad) {
|
||||||
|
console.log('MapView: Setting isInitialLoad to false');
|
||||||
setIsInitialLoad(false);
|
setIsInitialLoad(false);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -302,7 +280,6 @@ const MapView = () => {
|
|||||||
zoom={mapZoom}
|
zoom={mapZoom}
|
||||||
className="h-full w-full"
|
className="h-full w-full"
|
||||||
>
|
>
|
||||||
{shouldFitBounds && <FitBounds bounds={mapBounds} shouldFit={shouldFitBounds} />}
|
|
||||||
<TileLayer
|
<TileLayer
|
||||||
attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
||||||
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
||||||
|
|||||||
Reference in New Issue
Block a user