Skip to content

Commit 43f7625

Browse files
AE1NSA1Jan
andauthored
feat: Optimize @googlemaps/js-api-loader to use importLibrary method
Co-authored-by: [email protected] <[email protected]>
1 parent 583b0e5 commit 43f7625

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,13 @@ Supports markers of either either "legacy" or "advanced" types.
12741274
<code>google.maps.<a href="#marker">Marker</a> | google.maps.marker.AdvancedMarkerElement</code>
12751275

12761276

1277+
#### Marker
1278+
1279+
Supports markers of either either "legacy" or "advanced" types.
1280+
1281+
<code>google.maps.<a href="#marker">Marker</a> | google.maps.marker.AdvancedMarkerElement</code>
1282+
1283+
12771284
### Enums
12781285

12791286

plugin/src/web.ts

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

3434
export class CapacitorGoogleMapsWeb extends WebPlugin implements CapacitorGoogleMapsPlugin {
35-
private gMapsRef: typeof google.maps | undefined = undefined;
35+
private gMapsRef: google.maps.MapsLibrary | undefined = undefined;
3636
private AdvancedMarkerElement: typeof google.maps.marker.AdvancedMarkerElement | undefined = undefined;
3737
private PinElement: typeof google.maps.marker.PinElement | undefined = undefined;
3838
private maps: {
@@ -125,12 +125,10 @@ export class CapacitorGoogleMapsWeb extends WebPlugin implements CapacitorGoogle
125125
const loader = new lib.Loader({
126126
apiKey: apiKey ?? '',
127127
version: 'weekly',
128-
libraries: ['places'],
129128
language,
130129
region,
131130
});
132-
const google = await loader.load();
133-
this.gMapsRef = google.maps;
131+
this.gMapsRef = await loader.importLibrary('maps');
134132

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

0 commit comments

Comments
 (0)