diff --git a/apps/map/BUCK b/apps/map/BUCK index 83780d50c2..b904f516a9 100644 --- a/apps/map/BUCK +++ b/apps/map/BUCK @@ -37,6 +37,7 @@ filegroup( name = "src", srcs = glob([ "app/**", + "public/**", "theme/**", "services/**", "components/**", diff --git a/apps/map/app/page.tsx b/apps/map/app/page.tsx index 0d819695f2..6c6c2f2da3 100644 --- a/apps/map/app/page.tsx +++ b/apps/map/app/page.tsx @@ -1,4 +1,5 @@ import MapComponent from "@/components/map" +import { env } from "@/env" import { businessMapMarkers } from "@/services/galoy/graphql/queries/business-map-marker" import Image from "next/image" @@ -8,12 +9,13 @@ export default async function Home() { return
{mapData.message}
} + const googleMapsApiKey = env.NEXT_PUBLIC_MAP_API_KEY return (
Blink Logo
- +
) } diff --git a/apps/map/components/map/index.tsx b/apps/map/components/map/index.tsx index 9e85f41aa2..df1e8a833c 100644 --- a/apps/map/components/map/index.tsx +++ b/apps/map/components/map/index.tsx @@ -4,21 +4,22 @@ import { GoogleMap, MarkerF, InfoWindow, useLoadScript } from "@react-google-map import { BusinessMapMarkersQuery } from "@/services/galoy/graphql/generated" import Link from "next/link" import { theme } from "./map-theme" -import { env } from "@/env" import LocationIcon from "../logo/location" import { SuggestMapFormSheet } from "./suggest-form" type MapComponentProps = { mapData: BusinessMapMarkersQuery["businessMapMarkers"] + googleMapsApiKey: string } const DEFAULT_LAT = 13.7942 const DEFAULT_LNG = -88.8965 -export default function MapComponent({ mapData }: MapComponentProps) { +export default function MapComponent({ mapData, googleMapsApiKey }: MapComponentProps) { const mapRef = useRef() 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 }: MapComponentProps) { 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, @@ -73,7 +83,7 @@ export default function MapComponent({ mapData }: MapComponentProps) { }, []) const { isLoaded } = useLoadScript({ - googleMapsApiKey: env.NEXT_PUBLIC_MAP_API_KEY, + googleMapsApiKey, libraries: libraries as any, }) @@ -159,7 +169,14 @@ export default function MapComponent({ mapData }: MapComponentProps) { } return ( - <> +
{draggablePin.visible && (
@@ -229,7 +246,7 @@ export default function MapComponent({ mapData }: MapComponentProps) { zoom={14} center={currentLocation.coordinates} mapTypeId={google.maps.MapTypeId.ROADMAP} - mapContainerStyle={{ width: "100vw", height: "100vh" }} + mapContainerStyle={{ height: "100%", width: "100%" }} > {mapData.map((marker, index) => ( )} - +
) }