Skip to content

Commit

Permalink
feat(google-maps): Added ability for plugin to take already instanci…
Browse files Browse the repository at this point in the history
…ated google maps api
  • Loading branch information
A1Jan committed May 23, 2023
1 parent 5e53d83 commit 7e215e7
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions google-maps/src/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,22 @@ export class CapacitorGoogleMapsWeb
language?: string,
) {
if (this.gMapsRef === undefined) {
const lib = await import('@googlemaps/js-api-loader');
const loader = new lib.Loader({
apiKey: apiKey ?? '',
version: 'weekly',
libraries: ['places'],
language,
region,
});
const google = await loader.load();
this.gMapsRef = google.maps;
console.log('Loaded google maps API');
if (!window.google.maps) {
const lib = await import('@googlemaps/js-api-loader');
const loader = new lib.Loader({
apiKey: apiKey ?? '',
version: 'weekly',
libraries: ['places'],
language,
region,
});
const google = await loader.load();
this.gMapsRef = google.maps;
console.log('Loaded google maps API');
} else {
this.gMapsRef = window.google.maps;
console.log('Google maps API already loaded');
}
}
}

Expand Down

0 comments on commit 7e215e7

Please sign in to comment.