diff --git a/platform/src/common/components/Map/AirQoMap.jsx b/platform/src/common/components/Map/AirQoMap.jsx
index 9380b48918..f968b2df6e 100644
--- a/platform/src/common/components/Map/AirQoMap.jsx
+++ b/platform/src/common/components/Map/AirQoMap.jsx
@@ -33,7 +33,7 @@ const mapStyles = [
{ url: 'mapbox://styles/mapbox/satellite-v9', name: 'Satellite', image: SatelliteMode },
];
-const AirQoMap = ({ customStyle, mapboxApiAccessToken, showSideBar, pollutant }) => {
+const AirQoMap = ({ customStyle, mapboxApiAccessToken, showSideBar, pollutant, resizeMap }) => {
const dispatch = useDispatch();
const mapContainerRef = useRef(null);
const mapRef = useRef(null);
@@ -48,6 +48,7 @@ const AirQoMap = ({ customStyle, mapboxApiAccessToken, showSideBar, pollutant })
const [toastMessage, setToastMessage] = useState({
message: '',
type: '',
+ bgColor: '',
});
const [NodeType, setNodeType] = useState('Emoji');
const [selectedSite, setSelectedSite] = useState(null);
@@ -60,10 +61,13 @@ const AirQoMap = ({ customStyle, mapboxApiAccessToken, showSideBar, pollutant })
/**
* Clear data on unmount
* @sideEffect
- * - Clear data
+ * - Clear data on unmount when lat, lng and zm are not present
+ * @returns {void}
*/
useEffect(() => {
- dispatch(clearData());
+ if (!lat && !lng && !zm) {
+ dispatch(clearData());
+ }
}, []);
/**
@@ -129,6 +133,13 @@ const AirQoMap = ({ customStyle, mapboxApiAccessToken, showSideBar, pollutant })
/**
* Initialize the map
+ * @sideEffect
+ * - Initialize the map
+ * - Add map controls
+ * - Load data
+ * - Update clusters
+ * - Fetch location boundaries
+ * @returns {void}
*/
useEffect(() => {
const initializeMap = async () => {
@@ -263,6 +274,12 @@ const AirQoMap = ({ customStyle, mapboxApiAccessToken, showSideBar, pollutant })
const marker = new mapboxgl.Marker(el)
.setLngLat(feature.geometry.coordinates)
.addTo(map);
+
+ // Add click event to zoom in when a user clicks on a cluster
+ el.addEventListener('click', () => {
+ map.flyTo({ center: feature.geometry.coordinates, zoom: zoom + 2 });
+ });
+
markers.push(marker);
}
});
@@ -287,6 +304,17 @@ const AirQoMap = ({ customStyle, mapboxApiAccessToken, showSideBar, pollutant })
};
}, [mapStyle, mapboxApiAccessToken, refresh, pollutant, NodeType]);
+ /**
+ * Resize the map
+ * @sideEffect
+ * - Resizes the map when the window is resized and side bar is closed
+ */
+ useEffect(() => {
+ if (!resizeMap) {
+ mapRef.current.resize();
+ }
+ }, [!resizeMap]);
+
/**
* Fetch location boundaries
*/
@@ -399,6 +427,7 @@ const AirQoMap = ({ customStyle, mapboxApiAccessToken, showSideBar, pollutant })
setToastMessage({
message: 'Location URL copied to clipboard',
type: 'success',
+ bgColor: 'bg-blue-600',
});
} catch (error) {
setToastMessage({
@@ -409,17 +438,14 @@ const AirQoMap = ({ customStyle, mapboxApiAccessToken, showSideBar, pollutant })
};
return (
-
+
{/* Map */}
{/* Loader */}
{refresh ||
(loading && (
-
+
@@ -478,7 +504,7 @@ const AirQoMap = ({ customStyle, mapboxApiAccessToken, showSideBar, pollutant })
timeout={3000}
dataTestId='map-toast'
size='lg'
- bgColor='bg-blue-600'
+ bgColor={toastMessage.bgColor}
position='bottom'
/>
)}
diff --git a/platform/src/common/components/Map/components/LayerModal.js b/platform/src/common/components/Map/components/LayerModal.js
index 4c6d806f11..adeb77f187 100644
--- a/platform/src/common/components/Map/components/LayerModal.js
+++ b/platform/src/common/components/Map/components/LayerModal.js
@@ -35,7 +35,14 @@ const Option = ({ isSelected, children, onSelect, image, disabled }) => (
className={`w-14 h-14 relative rounded-lg ${
isSelected ? 'border-2 border-blue-500 ring-4 ring-light-blue-100' : ''
} border-2`}>
-
+
{children}
@@ -84,7 +91,7 @@ const LayerModal = ({
if (!isOpen) return null;
return (
-
+
diff --git a/platform/src/common/components/Map/components/MapControls.js b/platform/src/common/components/Map/components/MapControls.js
index 8f4eb87649..082de67d74 100644
--- a/platform/src/common/components/Map/components/MapControls.js
+++ b/platform/src/common/components/Map/components/MapControls.js
@@ -145,6 +145,7 @@ export class CustomGeolocateControl {
this.setToastMessage({
message: 'Location tracked successfully.',
type: 'success',
+ bgColor: 'bg-blue-600',
});
this.map.flyTo({
diff --git a/platform/src/common/components/Map/components/Sidebar.js b/platform/src/common/components/Map/components/Sidebar.js
index 9be9d24799..a37a36c4e2 100644
--- a/platform/src/common/components/Map/components/Sidebar.js
+++ b/platform/src/common/components/Map/components/Sidebar.js
@@ -180,10 +180,9 @@ const Sidebar = ({ siteDetails, selectedSites, isAdmin, showSideBar, setShowSide
return (
+ className={`w-auto h-full md:max-w-[400px] bg-white shadow-lg shadow-right space-y-4 z-50 overflow-y-auto map-scrollbar z-50 ${
+ window.innerWidth < 768 ? 'absolute left-0 top-0' : ''
+ }`}>
diff --git a/platform/src/common/components/Toast/index.jsx b/platform/src/common/components/Toast/index.jsx
index ecc821ead9..d5d3845f7b 100644
--- a/platform/src/common/components/Toast/index.jsx
+++ b/platform/src/common/components/Toast/index.jsx
@@ -27,7 +27,7 @@ const Toast = ({ message, type, timeout, dataTestId, size, clearData, bgColor, p
return visible ? (
diff --git a/platform/src/lib/store/services/map/MapSlice.js b/platform/src/lib/store/services/map/MapSlice.js
index 1f7bcbab86..7400cc6f35 100644
--- a/platform/src/lib/store/services/map/MapSlice.js
+++ b/platform/src/lib/store/services/map/MapSlice.js
@@ -6,10 +6,10 @@ const initialState = {
city: '',
},
center: {
- latitude: 2.4672,
- longitude: 9.8977,
+ latitude: 2.5768,
+ longitude: 25.1601,
},
- zoom: 3.0141218806815315,
+ zoom: 3.01,
};
export const mapSlice = createSlice({
diff --git a/platform/src/pages/Home/index.jsx b/platform/src/pages/Home/index.jsx
index 385a024076..b14c15bc98 100644
--- a/platform/src/pages/Home/index.jsx
+++ b/platform/src/pages/Home/index.jsx
@@ -188,7 +188,7 @@ const Home = () => {
+ className='text-blue-600 text-sm font-normal mt-2 cursor-pointer hidden'>
Show me how
@@ -200,7 +200,7 @@ const Home = () => {
}}>
+ className='absolute z-50 inset-0 flex items-center justify-center cursor-pointer hidden'>
diff --git a/platform/src/pages/map/index.jsx b/platform/src/pages/map/index.jsx
index cc4d858b7f..237058f894 100644
--- a/platform/src/pages/map/index.jsx
+++ b/platform/src/pages/map/index.jsx
@@ -61,44 +61,37 @@ const index = () => {
return (
-
- <>
- {showSideBar && (
-
- )}
-
-
-
-
-
-
+
+ {showSideBar && (
+
+ )}
+
+
+
+
+
- >
+
+