Skip to content

Commit 2857bff

Browse files
committed
feat(api-loader): allow string-array for libraries parameter
closes #3
1 parent 6bcbffa commit 2857bff

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/load-maps-api.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export type MapsApiOptions = {
22
key: string;
3-
libraries?: string;
3+
libraries?: string | string[];
44
v?: string;
55
};
66

@@ -11,13 +11,17 @@ export async function loadMapsApi(apiOptions: MapsApiOptions): Promise<void> {
1111
return mapsApiLoaded;
1212
}
1313

14+
if (Array.isArray(apiOptions.libraries)) {
15+
apiOptions.libraries = apiOptions.libraries.join(',');
16+
}
17+
1418
const apiUrl = new URL('https://maps.googleapis.com/maps/api/js');
1519
for (const [key, value] of Object.entries(apiOptions)) {
1620
if (value === undefined) {
1721
continue;
1822
}
1923

20-
apiUrl.searchParams.set(key, value);
24+
apiUrl.searchParams.set(key, value as string);
2125
}
2226
apiUrl.searchParams.set('callback', '__maps_callback__');
2327

0 commit comments

Comments
 (0)