Skip to content

Commit

Permalink
refactor(map): google maps api key passing
Browse files Browse the repository at this point in the history
  • Loading branch information
siddhart1o1 committed Feb 10, 2024
1 parent d3be4fd commit 5b074dd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions apps/map/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ filegroup(
name = "src",
srcs = glob([
"app/**",
"public/**",
"theme/**",
"services/**",
"components/**",
Expand Down
4 changes: 3 additions & 1 deletion apps/map/app/page.tsx
Original file line number Diff line number Diff line change
@@ -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"

Expand All @@ -8,12 +9,13 @@ export default async function Home() {
return <main>{mapData.message}</main>
}

const googleMapsApiKey = env.NEXT_PUBLIC_MAP_API_KEY
return (
<main>
<div className="absolute ml-1 mt-1 rounded-xl bg-clip-padding backdrop-filter backdrop-blur-sm bg-opacity-10 z-10">
<Image width={130} height={130} src={"/logo.svg"} alt="Blink Logo" />
</div>
<MapComponent mapData={mapData} />
<MapComponent googleMapsApiKey={googleMapsApiKey} mapData={mapData} />
</main>
)
}
6 changes: 3 additions & 3 deletions apps/map/components/map/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ 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<google.maps.Map>()
const [selectedMarker, setSelectedMarker] = useState<
BusinessMapMarkersQuery["businessMapMarkers"][number] | null
Expand Down Expand Up @@ -73,7 +73,7 @@ export default function MapComponent({ mapData }: MapComponentProps) {
}, [])

const { isLoaded } = useLoadScript({
googleMapsApiKey: env.NEXT_PUBLIC_MAP_API_KEY,
googleMapsApiKey,
libraries: libraries as any,
})

Expand Down

0 comments on commit 5b074dd

Please sign in to comment.