Skip to content

Commit f3085f5

Browse files
authored
Merge pull request #271 from map-of-pi/fix/markers-not-showing-on-page-load
Approved (1).
2 parents ff93aae + 78ac4d0 commit f3085f5

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/components/shared/map/Map.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,15 @@ const Map = ({
168168
setError(null);
169169
try {
170170
// Fetch the current map bounds
171-
const bounds = mapRef.current?.getBounds();
171+
// manually set bounds as mapref is null during component rendering phase
172+
const bounds = L.latLngBounds(
173+
L.latLng(-90, -180),
174+
L.latLng(90, 180)
175+
);
172176

173-
if (bounds) {
174-
let sellersData = await fetchSellerCoordinates(bounds, '');
175-
sellersData = removeDuplicates(sellersData);
176-
setSellers(sellersData);
177-
}
177+
let sellersData = await fetchSellerCoordinates(bounds, '');
178+
sellersData = removeDuplicates(sellersData);
179+
setSellers(sellersData);
178180
} catch (error) {
179181
logger.error('Failed to fetch initial coordinates:', { error });
180182
setError('Failed to fetch initial coordinates');

0 commit comments

Comments
 (0)