diff --git a/client/src/pages/MapView.jsx b/client/src/pages/MapView.jsx index 88c1248..a6c5981 100644 --- a/client/src/pages/MapView.jsx +++ b/client/src/pages/MapView.jsx @@ -183,42 +183,20 @@ const MapView = () => { console.log('MapView: fetchDevices - Device data received, length:', deviceData.length); setDevices(deviceData); - // Calculate bounds dynamically based on device locations + // Just log device bounds for reference, but don't use them if (deviceData.length > 0) { const lats = deviceData.map(device => device.geo_lat); const lons = deviceData.map(device => device.geo_lon); - const minLat = Math.min(...lats); const maxLat = Math.max(...lats); const minLon = Math.min(...lons); const maxLon = Math.max(...lons); - - // 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); - } + console.log('MapView: Device bounds (info only):', { minLat, maxLat, minLon, maxLon }); } - // Always mark initial load as complete after first fetch, regardless of device data + // Always mark initial load as complete after first fetch if (isInitialLoad) { + console.log('MapView: Setting isInitialLoad to false'); setIsInitialLoad(false); } } catch (error) { @@ -302,7 +280,6 @@ const MapView = () => { zoom={mapZoom} className="h-full w-full" > - {shouldFitBounds && }