Skip to content

Commit 92cff5d

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

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ export default MyMap;
319319
* [`enableAccessibilityElements(...)`](#enableaccessibilityelements)
320320
* [`enableCurrentLocation(...)`](#enablecurrentlocation)
321321
* [`setPadding(...)`](#setpadding)
322+
* [`getMapBounds()`](#getmapbounds)
322323
* [`fitBounds(...)`](#fitbounds)
323324
* [`setOnBoundsChangedListener(...)`](#setonboundschangedlistener)
324325
* [`setOnCameraIdleListener(...)`](#setoncameraidlelistener)
@@ -654,6 +655,19 @@ setPadding(padding: MapPadding) => Promise<void>
654655
--------------------
655656

656657

658+
### getMapBounds()
659+
660+
```typescript
661+
getMapBounds() => Promise<LatLngBounds>
662+
```
663+
664+
Get the map's current viewport latitude and longitude bounds.
665+
666+
**Returns:** <code>Promise&lt;LatLngBounds&gt;</code>
667+
668+
--------------------
669+
670+
657671
### fitBounds(...)
658672

659673
```typescript
@@ -1169,6 +1183,13 @@ but the current specification only allows X, Y, and (optionally) Z to be defined
11691183
<code>number[]</code>
11701184

11711185

1186+
#### Marker
1187+
1188+
Supports markers of either either "legacy" or "advanced" types.
1189+
1190+
<code>google.maps.<a href="#marker">Marker</a> | google.maps.marker.AdvancedMarkerElement</code>
1191+
1192+
11721193
### Enums
11731194

11741195

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)