From 553e19870fea0973cb054d1fba5821e5cf95c6e0 Mon Sep 17 00:00:00 2001 From: "jgessinger@aeins.de" Date: Tue, 9 May 2023 08:21:12 +0200 Subject: [PATCH] feat(google-maps): Optimize @googlemaps/js-api-loader to use importLibrary method --- google-maps/package.json | 4 ++-- google-maps/src/web.ts | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/google-maps/package.json b/google-maps/package.json index 91ffeef32..8a51a5214 100644 --- a/google-maps/package.json +++ b/google-maps/package.json @@ -93,8 +93,8 @@ "access": "public" }, "dependencies": { - "@googlemaps/js-api-loader": "~1.13.7", + "@googlemaps/js-api-loader": "~1.16.2", "@googlemaps/markerclusterer": "~2.0.7", - "@types/google.maps": "~3.50.5" + "@types/google.maps": "~3.53.4" } } diff --git a/google-maps/src/web.ts b/google-maps/src/web.ts index 5b82addec..2fcdbb432 100644 --- a/google-maps/src/web.ts +++ b/google-maps/src/web.ts @@ -39,7 +39,7 @@ export class CapacitorGoogleMapsWeb extends WebPlugin implements CapacitorGoogleMapsPlugin { - private gMapsRef: typeof google.maps | undefined = undefined; + private gMapsRef: google.maps.MapsLibrary | undefined = undefined; private maps: { [id: string]: { element: HTMLElement; @@ -126,12 +126,10 @@ export class CapacitorGoogleMapsWeb const loader = new lib.Loader({ apiKey: apiKey ?? '', version: 'weekly', - libraries: ['places'], language, region, }); - const google = await loader.load(); - this.gMapsRef = google.maps; + this.gMapsRef = await loader.importLibrary('maps'); console.log('Loaded google maps API'); } }