Skip to content

Commit

Permalink
feat(googleMaps): language & region params (#286)
Browse files Browse the repository at this point in the history
  • Loading branch information
morgan-retex authored Oct 11, 2024
1 parent 0c5135c commit e0369ed
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/runtime/registry/google-maps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ declare namespace google {
export const GoogleMapsOptions = object({
apiKey: string(),
libraries: optional(array(string())),
language: optional(string()),
region: optional(string()),
v: optional(union([literal('weekly'), literal('beta'), literal('alpha')])),
})

Expand All @@ -40,13 +42,17 @@ export function useScriptGoogleMaps<T extends GoogleMapsApi>(_options?: GoogleMa
let readyPromise: Promise<void> = Promise.resolve()
return useRegistryScript<T, typeof GoogleMapsOptions>('googleMaps', (options) => {
const libraries = options?.libraries || ['places']
const language = options?.language ? { language: options.language } : undefined
const region = options?.region ? { region: options.region } : undefined
return {
scriptInput: {
src: withQuery(`https://maps.googleapis.com/maps/api/js`, {
libraries: libraries.join(','),
key: options?.apiKey,
loading: 'async',
callback: 'google.maps.__ib__',
...language,
...region,
}),
},
clientInit: import.meta.server
Expand Down

0 comments on commit e0369ed

Please sign in to comment.