You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/scripts/content/google-maps.md
+272Lines changed: 272 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -380,6 +380,278 @@ By providing your own placeholder slot you will disable the default placeholder
380
380
</template>
381
381
```
382
382
383
+
## Google Maps SFC Components
384
+
385
+
Nuxt Scripts provides individual Single File Components (SFCs) for different Google Maps elements. These components allow you to declaratively compose complex maps using Vue's template syntax.
386
+
387
+
### Installation
388
+
389
+
To use marker clustering functionality, you'll need to install the required peer dependency:
390
+
391
+
```bash
392
+
npm install @googlemaps/markerclusterer
393
+
# or
394
+
yarn add @googlemaps/markerclusterer
395
+
# or
396
+
pnpm add @googlemaps/markerclusterer
397
+
```
398
+
399
+
### Available Components
400
+
401
+
All Google Maps SFC components must be used within a `<ScriptGoogleMaps>` component:
402
+
403
+
-`<ScriptGoogleMapsMarker>` - Classic markers with icon support
404
+
-`<ScriptGoogleMapsAdvancedMarkerElement>` - Modern advanced markers with HTML content
405
+
-`<ScriptGoogleMapsPinElement>` - Customizable pin markers (use within AdvancedMarkerElement)
406
+
-`<ScriptGoogleMapsInfoWindow>` - Information windows that appear on click
407
+
-`<ScriptGoogleMapsMarkerClusterer>` - Groups nearby markers into clusters
Always provide error fallbacks and loading states:
633
+
634
+
```vue
635
+
<script setup>
636
+
const mapError = ref(false)
637
+
</script>
638
+
639
+
<template>
640
+
<ScriptGoogleMaps
641
+
@error="mapError = true"
642
+
api-key="your-api-key"
643
+
>
644
+
<template #error>
645
+
<div class="p-4 bg-red-100">
646
+
Failed to load Google Maps
647
+
</div>
648
+
</template>
649
+
650
+
<!-- Your components -->
651
+
</ScriptGoogleMaps>
652
+
</template>
653
+
```
654
+
383
655
## useScriptGoogleMaps
384
656
385
657
The `useScriptGoogleMaps` composable lets you have fine-grain control over the Google Maps SDK. It provides a way to load the Google Maps SDK and interact with it programmatically.
0 commit comments