diff --git a/src/components/__tests__/api-provider.test.tsx b/src/components/__tests__/api-provider.test.tsx index af1e0146..010f391b 100644 --- a/src/components/__tests__/api-provider.test.tsx +++ b/src/components/__tests__/api-provider.test.tsx @@ -73,7 +73,7 @@ test('passes parameters to GoogleMapsAPILoader', () => { expect(apiLoadSpy.mock.lastCall[0]).toMatchObject({ key: 'apikey', libraries: 'places,marker', - version: 'beta', + v: 'beta', language: 'en', region: 'us', authReferrerPolicy: 'origin' diff --git a/src/components/api-provider.tsx b/src/components/api-provider.tsx index 0908d092..c9f4b0aa 100644 --- a/src/components/api-provider.tsx +++ b/src/components/api-provider.tsx @@ -97,7 +97,7 @@ function useMapInstances() { * @param props */ function useGoogleMapsApiLoader(props: APIProviderProps) { - const {onLoad, apiKey, libraries = [], ...otherApiParams} = props; + const {onLoad, apiKey, version, libraries = [], ...otherApiParams} = props; const [status, setStatus] = useState( GoogleMapsApiLoader.loadingStatus @@ -114,8 +114,8 @@ function useGoogleMapsApiLoader(props: APIProviderProps) { const librariesString = useMemo(() => libraries?.join(','), [libraries]); const serializedParams = useMemo( - () => JSON.stringify(otherApiParams), - [otherApiParams] + () => JSON.stringify({apiKey, version, ...otherApiParams}), + [apiKey, version, otherApiParams] ); const importLibrary: typeof google.maps.importLibrary = useCallback( @@ -146,6 +146,7 @@ function useGoogleMapsApiLoader(props: APIProviderProps) { await GoogleMapsApiLoader.load( { key: apiKey, + v: version, libraries: librariesString, ...otherApiParams },