Skip to content

Commit 3e860cf

Browse files
theproducerWallsStarring
authored andcommitted
feat: Google Maps npm library updates (ionic-team#151)
1 parent dd21395 commit 3e860cf

File tree

6 files changed

+461
-401
lines changed

6 files changed

+461
-401
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,25 @@ const MyMap: React.FC = () => {
245245
export default MyMap;
246246
```
247247

248+
You may need to create a `*.d.ts` file for the custom element in React:
249+
250+
```ts
251+
// custom-elements.d.ts
252+
253+
declare module "react" {
254+
namespace JSX {
255+
interface IntrinsicElements {
256+
"capacitor-google-map": React.DetailedHTMLProps<
257+
React.HTMLAttributes<HTMLElement>,
258+
HTMLElement
259+
>;
260+
}
261+
}
262+
}
263+
264+
export {};
265+
```
266+
248267
### Vue
249268

250269
```vue
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import '@capacitor/google-maps';
2-
3-
declare global {
1+
declare module "react" {
42
namespace JSX {
53
interface IntrinsicElements {
6-
'capacitor-google-map': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4+
"capacitor-google-map": React.DetailedHTMLProps<
5+
React.HTMLAttributes<HTMLElement>,
6+
HTMLElement
7+
>;
78
}
89
}
910
}
1011

1112
export {};
12-

plugin/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,25 @@ const MyMap: React.FC = () => {
245245
export default MyMap;
246246
```
247247

248+
You may need to create a `*.d.ts` file for the custom element in React:
249+
250+
```ts
251+
// custom-elements.d.ts
252+
253+
declare module "react" {
254+
namespace JSX {
255+
interface IntrinsicElements {
256+
"capacitor-google-map": React.DetailedHTMLProps<
257+
React.HTMLAttributes<HTMLElement>,
258+
HTMLElement
259+
>;
260+
}
261+
}
262+
}
263+
264+
export {};
265+
```
266+
248267
### Vue
249268

250269
```vue

plugin/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"@typescript-eslint/eslint-plugin": "^8.48.0",
7070
"@typescript-eslint/parser": "^8.48.0",
7171
"downlevel-dts": "^0.11.0",
72-
"eslint": "^9.39.1",
72+
"eslint": "^8.57.1",
7373
"eslint-config-prettier": "^10.1.8",
7474
"eslint-plugin-import": "^2.32.0",
7575
"prettier": "^3.6.2",
@@ -96,8 +96,8 @@
9696
"access": "public"
9797
},
9898
"dependencies": {
99-
"@googlemaps/js-api-loader": "~1.16.8",
100-
"@googlemaps/markerclusterer": "~2.5.3",
101-
"@types/google.maps": "~3.58.1"
99+
"@googlemaps/js-api-loader": "^2.0.2",
100+
"@googlemaps/markerclusterer": "^2.6.2",
101+
"@types/google.maps": "^3.58.1"
102102
}
103103
}

plugin/src/web.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ export class CapacitorGoogleMapsWeb extends WebPlugin implements CapacitorGoogle
122122
private async importGoogleLib(apiKey: string, region?: string, language?: string) {
123123
if (this.gMapsRef === undefined) {
124124
const lib = await import('@googlemaps/js-api-loader');
125-
const loader = new lib.Loader({
126-
apiKey: apiKey ?? '',
127-
version: 'weekly',
125+
lib.setOptions({
126+
key: apiKey ?? '',
128127
language,
129128
region,
130129
});
131-
this.gMapsRef = await loader.importLibrary('maps');
130+
131+
this.gMapsRef = await lib.importLibrary('maps');
132132

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

0 commit comments

Comments
 (0)