Skip to content

Commit

Permalink
Merge pull request #1443 from Kjagd/feat/support-map-ids
Browse files Browse the repository at this point in the history
Support map ids for vector maps
  • Loading branch information
JustFly1984 committed Sep 28, 2020
2 parents 45814c6 + a9f1ad7 commit ca6ef34
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/react-google-maps-api/src/useLoadScript.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export function useLoadScript({
libraries,
preventGoogleFontsLoading,
channel,
mapIds,
}: UseLoadScriptOptions): {
isLoaded: boolean
loadError: Error | undefined
Expand Down Expand Up @@ -73,6 +74,7 @@ export function useLoadScript({
region,
libraries,
channel,
mapIds
})

React.useEffect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface LoadScriptUrlOptions {
region?: string
libraries?: string[]
channel?: string
mapIds?: string[]
}

export function makeLoadScriptUrl({
Expand All @@ -18,6 +19,7 @@ export function makeLoadScriptUrl({
region,
libraries,
channel,
mapIds
}: LoadScriptUrlOptions): string {
const params = []

Expand Down Expand Up @@ -52,6 +54,10 @@ export function makeLoadScriptUrl({
params.push(`channel=${channel}`)
}

if (mapIds && mapIds.length) {
params.push(`map_ids=${mapIds.join(',')}`)
}

params.push('callback=initMap')

return `https://maps.googleapis.com/maps/api/js?${params.join('&')}`
Expand Down

0 comments on commit ca6ef34

Please sign in to comment.