diff --git a/plugin/src/web.ts b/plugin/src/web.ts index 3c409eb..aa447e2 100644 --- a/plugin/src/web.ts +++ b/plugin/src/web.ts @@ -30,6 +30,7 @@ import type { RemovePolylinesArgs, RemoveTileOverlayArgs, } from './implementation'; +import { importLibrary, setOptions } from '@googlemaps/js-api-loader'; export class CapacitorGoogleMapsWeb extends WebPlugin implements CapacitorGoogleMapsPlugin { private gMapsRef: google.maps.MapsLibrary | undefined = undefined; @@ -121,19 +122,16 @@ export class CapacitorGoogleMapsWeb extends WebPlugin implements CapacitorGoogle private async importGoogleLib(apiKey: string, region?: string, language?: string) { if (this.gMapsRef === undefined) { - const lib = await import('@googlemaps/js-api-loader'); - lib.setOptions({ + setOptions({ key: apiKey ?? '', + v: 'weekly', language, region, }); - - this.gMapsRef = await lib.importLibrary('maps'); + this.gMapsRef = await importLibrary('maps'); // Import marker library once - const { AdvancedMarkerElement, PinElement } = (await google.maps.importLibrary( - 'marker', - )) as google.maps.MarkerLibrary; + const { AdvancedMarkerElement, PinElement } = await importLibrary('marker'); this.AdvancedMarkerElement = AdvancedMarkerElement; this.PinElement = PinElement;