diff --git a/apps/map/components/map/index.tsx b/apps/map/components/map/index.tsx index 8e740afc63..df1e8a833c 100644 --- a/apps/map/components/map/index.tsx +++ b/apps/map/components/map/index.tsx @@ -19,6 +19,7 @@ export default function MapComponent({ mapData, googleMapsApiKey }: MapComponent const [selectedMarker, setSelectedMarker] = useState< BusinessMapMarkersQuery["businessMapMarkers"][number] | null >(null) + const [viewportHeight, setViewportHeight] = useState("100vh") const [currentLocation, setCurrentLocation] = useState({ coordinates: { lat: DEFAULT_LAT, @@ -27,6 +28,15 @@ export default function MapComponent({ mapData, googleMapsApiKey }: MapComponent userAllowedLocation: false, }) + useEffect(() => { + const calculateViewportHeight = () => { + setViewportHeight(`${window.innerHeight}px`) + } + calculateViewportHeight() + window.addEventListener("resize", calculateViewportHeight) + return () => window.removeEventListener("resize", calculateViewportHeight) + }, []) + const [draggablePin, setDraggablePin] = useState({ coordinates: { lat: 0, lng: 0 }, visible: false, @@ -159,7 +169,14 @@ export default function MapComponent({ mapData, googleMapsApiKey }: MapComponent } return ( - <> +
{draggablePin.visible && (
@@ -229,7 +246,7 @@ export default function MapComponent({ mapData, googleMapsApiKey }: MapComponent zoom={14} center={currentLocation.coordinates} mapTypeId={google.maps.MapTypeId.ROADMAP} - mapContainerStyle={{ width: "100vw", height: "100vh" }} + mapContainerStyle={{ height: "100%", width: "100%" }} > {mapData.map((marker, index) => ( )} - +
) }