Skip to content

Commit 6bb30e7

Browse files
committed
fix(google-maps-provider): fixes advanced markers break map loading
1 parent 195c969 commit 6bb30e7

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

library/src/google-maps-provider.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ export interface GoogleMapsContextType {
2929
map?: google.maps.Map;
3030
}
3131

32+
// Declare global maps callback function
33+
declare global {
34+
interface Window {
35+
mapsCallback: () => void;
36+
}
37+
}
38+
3239
/**
3340
* The Google Maps context
3441
*/
@@ -76,7 +83,7 @@ export const GoogleMapsProvider: React.FunctionComponent<
7683
language: language || defaultLanguage,
7784
region: region || defaultRegion,
7885
...(libraries?.length && {libraries: libraries.join(',')}),
79-
...(version && {version}),
86+
...(version && {v: version}),
8087
...(authReferrerPolicy && {auth_referrer_policy: authReferrerPolicy})
8188
});
8289
/* eslint-enable camelcase */
@@ -118,10 +125,16 @@ export const GoogleMapsProvider: React.FunctionComponent<
118125
// Load Google Maps API
119126
setIsLoadingAPI(true);
120127

128+
// Add google maps callback
129+
window.mapsCallback = () => {
130+
apiLoadingFinished();
131+
};
132+
133+
params.set('callback', 'mapsCallback');
134+
121135
const scriptTag = document.createElement('script');
122136
scriptTag.type = 'text/javascript';
123137
scriptTag.src = `${GOOGLE_MAPS_API_URL}?${params.toString()}`;
124-
scriptTag.onload = apiLoadingFinished;
125138
document.getElementsByTagName('head')[0].appendChild(scriptTag);
126139
}
127140

0 commit comments

Comments
 (0)