Skip to content

Commit 7ade34e

Browse files
committed
feat(google-maps): Optimize @googlemaps/js-api-loader to use importLibrary method
1 parent ac36a4f commit 7ade34e

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

plugin/src/web.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import type {
3030
} from './implementation';
3131

3232
export class CapacitorGoogleMapsWeb extends WebPlugin implements CapacitorGoogleMapsPlugin {
33-
private gMapsRef: typeof google.maps | undefined = undefined;
33+
private gMapsRef: google.maps.MapsLibrary | undefined = undefined;
3434
private AdvancedMarkerElement: typeof google.maps.marker.AdvancedMarkerElement | undefined = undefined;
3535
private PinElement: typeof google.maps.marker.PinElement | undefined = undefined;
3636
private maps: {
@@ -119,12 +119,10 @@ export class CapacitorGoogleMapsWeb extends WebPlugin implements CapacitorGoogle
119119
const loader = new lib.Loader({
120120
apiKey: apiKey ?? '',
121121
version: 'weekly',
122-
libraries: ['places'],
123122
language,
124123
region,
125124
});
126-
const google = await loader.load();
127-
this.gMapsRef = google.maps;
125+
this.gMapsRef = await loader.importLibrary('maps');
128126

129127
// Import marker library once
130128
const { AdvancedMarkerElement, PinElement } = (await google.maps.importLibrary(

0 commit comments

Comments
 (0)