Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,25 @@ const MyMap: React.FC = () => {
export default MyMap;
```

You may need to create a `*.d.ts` file for the custom element in React:

```ts
// custom-elements.d.ts

declare module "react" {
namespace JSX {
interface IntrinsicElements {
"capacitor-google-map": React.DetailedHTMLProps<
React.HTMLAttributes<HTMLElement>,
HTMLElement
>;
}
}
}

export {};
```

### Vue

```vue
Expand Down
10 changes: 5 additions & 5 deletions example-app-spm/src/custom-elements.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import '@capacitor/google-maps';

declare global {
declare module "react" {
namespace JSX {
interface IntrinsicElements {
'capacitor-google-map': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
"capacitor-google-map": React.DetailedHTMLProps<
React.HTMLAttributes<HTMLElement>,
HTMLElement
>;
}
}
}

export {};

19 changes: 19 additions & 0 deletions plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,25 @@ const MyMap: React.FC = () => {
export default MyMap;
```

You may need to create a `*.d.ts` file for the custom element in React:

```ts
// custom-elements.d.ts

declare module "react" {
namespace JSX {
interface IntrinsicElements {
"capacitor-google-map": React.DetailedHTMLProps<
React.HTMLAttributes<HTMLElement>,
HTMLElement
>;
}
}
}

export {};
```

### Vue

```vue
Expand Down
8 changes: 4 additions & 4 deletions plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"@typescript-eslint/eslint-plugin": "^8.48.0",
"@typescript-eslint/parser": "^8.48.0",
"downlevel-dts": "^0.11.0",
"eslint": "^9.39.1",
"eslint": "^8.57.1",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-import": "^2.32.0",
"prettier": "^3.6.2",
Expand All @@ -95,8 +95,8 @@
"access": "public"
},
"dependencies": {
"@googlemaps/js-api-loader": "~1.16.8",
"@googlemaps/markerclusterer": "~2.5.3",
"@types/google.maps": "~3.58.1"
"@googlemaps/js-api-loader": "^2.0.2",
"@googlemaps/markerclusterer": "^2.6.2",
"@types/google.maps": "^3.58.1"
}
}
8 changes: 4 additions & 4 deletions plugin/src/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ 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');
const loader = new lib.Loader({
apiKey: apiKey ?? '',
version: 'weekly',
lib.setOptions({
key: apiKey ?? '',
language,
region,
});
this.gMapsRef = await loader.importLibrary('maps');

this.gMapsRef = await lib.importLibrary('maps');
Comment on lines +125 to +131
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Looks like this ends up addressing #147 (for which there was an alternative PR, that I guess becomes obsolete if this gets merged).

The PR title may need a rename because of this - explicitly mention updates to google maps, mention refactor of loader? Idk, I'll leave it to you @theproducer heh


// Import marker library once
const { AdvancedMarkerElement, PinElement } = (await google.maps.importLibrary(
Expand Down
Loading