---
title: "useScriptGoogleMaps() · Nuxt Scripts"
description: "Load the Google Maps SDK and access its API directly from a composable."
canonical_url: "https://scripts.nuxt.com/scripts/google-maps/api/use-script-google-maps"
meta:
  "og:description": "Load the Google Maps SDK and access its API directly from a composable."
  "og:image": "https://scripts.nuxt.com/_og/s/o_231693d0715fde09.png"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "useScriptGoogleMaps() · Nuxt Scripts"
  "twitter:image": "https://scripts.nuxt.com/_og/s/o_231693d0715fde09.png"
---

> Index of every page on this site: [llms.txt](https://scripts.nuxt.com/llms.txt)

**Api**

# **useScriptGoogleMaps()**

[Copy for LLMs](https://scripts.nuxt.com/scripts/google-maps/api/use-script-google-maps.md)

Use [`**useScriptGoogleMaps()**`](https://scripts.nuxt.com/scripts/google-maps/api/use-script-google-maps) to load the SDK and work with the Maps API directly.

```ts
export function useScriptGoogleMaps<T extends GoogleMapsApi>(_options?: GoogleMapsInput) {}
```

For triggers and other script options, see [**Registry Scripts**](https://scripts.nuxt.com/docs/guides/registry-scripts).

## Options

| **Option** | **Type** | **Default** | **Description** |
| --- | --- | --- | --- |
| `**apiKey**` | `**string**` | - | Your Google Maps API key (required). |
| `**libraries**` | `**string[]**` | `**['places']**` | Google Maps libraries to load. |
| `**language**` | `**string**` | - | Language for controls and labels (e.g., `**'en'**`, `**'ja'**`). |
| `**region**` | `**string**` | - | Region biasing (e.g., `**'US'**`, `**'JP'**`). |
| `**v**` | `**string**` | - | API version: `**'weekly'**`, `**'quarterly'**`, `**'beta'**`, or `**'alpha'**`. Omitted by default (Google defaults to `**'weekly'**`). |

## Return Values

| **Property** | **Type** | **Description** |
| --- | --- | --- |
| `**onLoaded**` | `**(fn) => void**` | Callback after the loader script finishes. Receives `**{ maps: Promise<typeof google.maps> }**`; await `**maps**` for the API callback. |
| `**load**` | `**() => Promise<GoogleMapsApi>**` | Manually trigger script loading. |
| `**status**` | `**Ref<string>**` | Current loading status (`**'awaitingLoad'**`, `**'loading'**`, `**'loaded'**`, `**'error'**`, or `**'removed'**`). |

## Examples

### Basic Map

Loading the Google Maps SDK and creating a map programmatically.

```vue
<script setup lang="ts">
/// <reference types="google.maps" />
const { onLoaded } = useScriptGoogleMaps({
  apiKey: 'key',
})
const mapEl = ref()
onMounted(() => {
  onLoaded(async (instance) => {
    const maps = await instance.maps
    new maps.Map(mapEl.value, {
      center: { lat: -34.397, lng: 150.644 },
      zoom: 8,
    })
  })
})
</script>

<template>
  <div ref="mapEl" style="width: 100%; height: 400px;" />
</template>
```

### Geocoding

Use the composable to access the Geocoder API.

```vue
<script setup lang="ts">
const { onLoaded } = useScriptGoogleMaps({
  apiKey: 'key',
})

async function geocodeAddress(address: string) {
  onLoaded(async (instance) => {
    const maps = await instance.maps
    const geocoder = new maps.Geocoder()
    const result = await geocoder.geocode({ address })
    console.log(result.results[0]?.geometry.location.toJSON())
  })
}
</script>
```

### Import additional libraries

Load an additional library at runtime. The registry already requests `**places**` by default, so this example imports `**geometry**`:

```vue
<script setup lang="ts">
const { onLoaded } = useScriptGoogleMaps({
  apiKey: 'key',
})

onMounted(() => {
  onLoaded(async (instance) => {
    const maps = await instance.maps
    const geometry = await maps.importLibrary('geometry')
    console.log(geometry.spherical)
  })
})
</script>
```

Prefer the [`**<ScriptGoogleMaps>**`](https://scripts.nuxt.com/scripts/google-maps/api/script-google-maps) component for most use cases. It handles lazy loading, placeholder images, and provides a declarative API. Use `**useScriptGoogleMaps()**` when you need direct SDK access or are building custom integrations.

Google removed the Drawing Library and Heatmap Layer from Maps JavaScript API 3.65 in May 2026. Although current project types still mention `**drawing**` and `**visualization**`, do not use them for new integrations. See Google's [**completed deprecations**](https://developers.google.com/maps/deprecations#completed-deprecations).

[Edit this page](https://github.com/nuxt/scripts/edit/main/docs/content/google-maps/2.api/12.use-script-google-maps.md)

[Markdown For LLMs](https://scripts.nuxt.com/scripts/google-maps/api/use-script-google-maps.md)

[**\<ScriptGoogleMapsOverlayView>** Position custom Vue content over a Google map or marker.](https://scripts.nuxt.com/scripts/google-maps/api/overlay-view) [**\<ScriptGoogleMapsStaticMap>** Render a Google Maps Static API image directly from Google.](https://scripts.nuxt.com/scripts/google-maps/api/static-map)

**On this page **

- [Options](#options)
- [Return Values](#return-values)
- [Examples](#examples)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://scripts.nuxt.com/#website","@type":"WebSite","description":"Nuxt Scripts lets you load third-party scripts with better performance, privacy, security and DX. It includes many popular third-parties out of the box.","name":"Nuxt Scripts","url":"https://scripts.nuxt.com/","publisher":{"@id":"https://scripts.nuxt.com/#identity"}},{"@id":"https://scripts.nuxt.com/scripts/google-maps/api/use-script-google-maps#webpage","@type":"WebPage","description":"Load the Google Maps SDK and access its API directly from a composable.","name":"useScriptGoogleMaps()","url":"https://scripts.nuxt.com/scripts/google-maps/api/use-script-google-maps","breadcrumb":{"@id":"https://scripts.nuxt.com/scripts/google-maps/api/use-script-google-maps#breadcrumb"},"isPartOf":{"@id":"https://scripts.nuxt.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://scripts.nuxt.com/scripts/google-maps/api/use-script-google-maps"]}],"primaryImageOfPage":{"@id":"https://scripts.nuxt.com/#logo"}},{"@id":"https://scripts.nuxt.com/#identity","@type":"Organization","name":"Nuxt Scripts","url":"https://scripts.nuxt.com","logo":{"@id":"https://scripts.nuxt.com/#logo"}},{"@id":"https://scripts.nuxt.com/scripts/google-maps/api/use-script-google-maps#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Nuxt Scripts","item":"https://scripts.nuxt.com/","position":1},{"@type":"ListItem","name":"Scripts","item":"https://scripts.nuxt.com/scripts","position":2},{"@type":"ListItem","name":"Google Maps","item":"https://scripts.nuxt.com/scripts/google-maps","position":3},{"@type":"ListItem","name":"API","item":"https://scripts.nuxt.com/scripts/google-maps/api","position":4},{"@type":"ListItem","name":"useScriptGoogleMaps()","item":"https://scripts.nuxt.com/scripts/google-maps/api/use-script-google-maps","position":5}]},{"@id":"https://scripts.nuxt.com/#logo","@type":"ImageObject","caption":"Nuxt Scripts","contentUrl":"https://scripts.nuxt.com/logo.svg","inLanguage":"en","url":"https://scripts.nuxt.com/logo.svg"}]}
```

## Sitemap

See the full [sitemap](https://scripts.nuxt.com/sitemap.md) for all pages.
