Skip to content

Commit

Permalink
feat(google-maps): Added ability for plugin to take already instancia…
Browse files Browse the repository at this point in the history
…ted google maps api
  • Loading branch information
A1Jan committed May 9, 2023
1 parent 8a2e0ea commit cbf61a3
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions google-maps/src/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,20 @@ export class CapacitorGoogleMapsWeb

private async importGoogleLib(apiKey: string) {
if (this.gMapsRef === undefined) {
const lib = await import('@googlemaps/js-api-loader');
const loader = new lib.Loader({
apiKey: apiKey ?? '',
version: 'weekly',
libraries: ['places'],
});
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'],
});
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 cbf61a3

Please sign in to comment.