---
title: "<ScriptGoogleMapsOverlayView> · Nuxt Scripts"
description: "Position custom Vue content over a Google map or marker."
canonical_url: "https://scripts.nuxt.com/scripts/google-maps/api/overlay-view"
meta:
  "og:description": "Position custom Vue content over a Google map or marker."
  "og:image": "https://scripts.nuxt.com/_og/s/o_6aaec0074fc2017a.png"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "<ScriptGoogleMapsOverlayView> · Nuxt Scripts"
  "twitter:image": "https://scripts.nuxt.com/_og/s/o_6aaec0074fc2017a.png"
---

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

**Api**

# **\<ScriptGoogleMapsOverlayView>**

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

Renders Vue slot content at a map latitude and longitude using Google's [`**OverlayView**`](https://developers.google.com/maps/documentation/javascript/customoverlays). Unlike `**InfoWindow**`, it leaves the HTML structure and styling to you.

`**position**``google.maps.LatLng | google.maps.LatLngLiteral`

Geographic position for the overlay. Falls back to parent marker position if omitted. Accepts either a plain \`LatLngLiteral\` (\`{ lat, lng }\`) or a \`google.maps.LatLng\` instance.

`**defaultOpen**``boolean` = true

Initial open state for the uncontrolled mode (when \`v-model:open\` is not bound). When omitted, the overlay opens on mount, matching v0 behaviour. Has no effect when \`v-model:open\` is used; pass an initial value to the bound ref instead.

`**anchor**``ScriptGoogleMapsOverlayAnchor` = 'bottom-center'

Anchor point of the overlay relative to its position.

`**offset**``{ x: number, y: number }`

Pixel offset from the anchor position.

`**pane**``ScriptGoogleMapsOverlayPane` = 'floatPane'

The map pane on which to render the overlay.

`**zIndex**``number`

CSS z-index for the overlay element.

`**blockMapInteraction**``boolean` = true

Whether to block map click and gesture events from passing through the overlay.

`**panOnOpen**``boolean | number` = true

Pan the map so the overlay is fully visible when opened, similar to InfoWindow behavior. Set to \`true\` for default 40px padding, or a number for custom padding.

`**hideWhenClustered**``boolean` = true

Automatically hide the overlay when its parent marker joins a cluster (on zoom out). Only applies when nested inside a ScriptGoogleMapsMarkerClusterer.

`**v-model:open**``boolean`

## Marker Anchoring

When nested inside a `**ScriptGoogleMapsMarker**`, the overlay inherits the marker's position and follows it while it is dragged.

```vue
<template>
  <ScriptGoogleMaps api-key="your-api-key">
    <ScriptGoogleMapsMarker
      :position="{ lat: -34.397, lng: 150.644 }"
      :options="{ gmpDraggable: true }"
    >
      <ScriptGoogleMapsOverlayView
        anchor="bottom-center"
        :offset="{ x: 0, y: -50 }"
      >
        <div class="custom-tooltip">
          Custom Vue content
        </div>
      </ScriptGoogleMapsOverlayView>
    </ScriptGoogleMapsMarker>
  </ScriptGoogleMaps>
</template>
```

## Controlled vs Uncontrolled Open State

The overlay supports two open-state patterns: uncontrolled (component-managed) and controlled (parent-managed via `**v-model:open**`).

**Uncontrolled.** The component owns its open state. The overlay opens by default; pass `**:default-open="false"**` to start closed. This is the simplest pattern when you don't need to react to state changes from the parent.

```vue
<template>
  <!-- Opens immediately on mount (default) -->
  <ScriptGoogleMapsOverlayView :position="{ lat: -34.397, lng: 150.644 }">
    <div>Always-open label</div>
  </ScriptGoogleMapsOverlayView>

  <!-- Remains closed; use v-model:open when it needs to toggle -->
  <ScriptGoogleMapsOverlayView
    :position="{ lat: -34.397, lng: 150.644 }"
    :default-open="false"
  >
    <div>Initially hidden</div>
  </ScriptGoogleMapsOverlayView>
</template>
```

**Controlled.** Bind `**v-model:open**` to a parent ref. The parent owns the state and the overlay reflects it. The overlay updates the bound ref when something internal flips it (for example, the marker-cluster auto-hide behavior).

```vue
<script setup lang="ts">
const open = ref(true)
</script>

<template>
  <ScriptGoogleMapsOverlayView v-model:open="open" :position="{ lat: -34.397, lng: 150.644 }">
    <div>Controlled by parent</div>
  </ScriptGoogleMapsOverlayView>
</template>
```

When `**v-model:open**` is bound, `**defaultOpen**` has no effect; pass an initial value to the bound ref instead.

An uncontrolled overlay that starts with `**defaultOpen: false**` has no public method for opening it later. Bind `**v-model:open**` for any overlay that needs to toggle.

## Popup on Marker Click

Using `**v-model:open**` keeps the overlay mounted, toggling visibility via CSS. This avoids remount cost and preserves internal state.

```vue
<script setup lang="ts">
const open = ref(false)
</script>

<template>
  <ScriptGoogleMaps api-key="your-api-key">
    <ScriptGoogleMapsMarker
      :position="{ lat: -34.397, lng: 150.644 }"
      @click="open = !open"
    >
      <ScriptGoogleMapsOverlayView
        v-model:open="open"
        anchor="bottom-center"
        :offset="{ x: 0, y: -50 }"
      >
        <div class="custom-popup">
          <button @click.stop="open = false">
            ×
          </button>
          <p>Any Vue content here</p>
        </div>
      </ScriptGoogleMapsOverlayView>
    </ScriptGoogleMapsMarker>
  </ScriptGoogleMaps>
</template>
```

For simple cases where remounting is acceptable, `**v-if**` also works:

```vue
<ScriptGoogleMapsMarker
  :position="{ lat: -34.397, lng: 150.644 }"
  @click="open = true"
>
  <ScriptGoogleMapsOverlayView v-if="open">
    <MyPopup @close="open = false" />
  </ScriptGoogleMapsOverlayView>
</ScriptGoogleMapsMarker>
```

## Persistent Label

```vue
<template>
  <ScriptGoogleMaps api-key="your-api-key">
    <ScriptGoogleMapsOverlayView
      :position="{ lat: -34.397, lng: 150.644 }"
      anchor="center"
      :block-map-interaction="false"
    >
      <span class="bg-white px-1.5 py-0.5 rounded">
        Label text
      </span>
    </ScriptGoogleMapsOverlayView>
  </ScriptGoogleMaps>
</template>
```

## Position Format

The `**position**` prop accepts either a plain `**LatLngLiteral**` (`**{ lat, lng }**`) or a `**google.maps.LatLng**` instance, so you can pass values straight from the Maps API without converting them first.

```vue
<script setup lang="ts">
const mapRef = ref()

async function showSydney() {
  // Resolve a query into a LatLng-shaped value via the Maps API
  const sydney = await mapRef.value?.resolveQueryToLatLng('Sydney, Australia')
  // Pass it through unchanged: works for both shapes
  position.value = sydney
}

const position = ref()
</script>

<template>
  <ScriptGoogleMaps ref="mapRef" api-key="your-api-key">
    <ScriptGoogleMapsOverlayView v-if="position" :position="position">
      <div>Resolved position</div>
    </ScriptGoogleMapsOverlayView>
  </ScriptGoogleMaps>
</template>
```

## Map Panning

When an already-open overlay first attaches to the map, it pans into view with 40px of padding. Toggling a mounted overlay from closed to open does not currently run the pan step again.

To customize the padding or disable panning:

```vue
<!-- Custom padding -->
<ScriptGoogleMapsOverlayView :pan-on-open="60">
  ...
</ScriptGoogleMapsOverlayView>

<!-- Disable panning -->
<ScriptGoogleMapsOverlayView :pan-on-open="false">
  ...
</ScriptGoogleMapsOverlayView>
```

## Cluster Awareness

When used inside a `**ScriptGoogleMapsMarkerClusterer**`, overlay views automatically hide when their parent marker joins a cluster on zoom out. This prevents orphaned overlays from floating over cluster icons.

When its marker is clustered, the overlay updates `**v-model:open**` to `**false**`. The user will need to reopen the overlay (e.g. click the marker again) after zooming back in.

To disable this behavior:

```vue
<ScriptGoogleMapsMarkerClusterer>
  <ScriptGoogleMapsMarker :position="markerPosition">
    <ScriptGoogleMapsOverlayView :hide-when-clustered="false">
      ...
    </ScriptGoogleMapsOverlayView>
  </ScriptGoogleMapsMarker>
</ScriptGoogleMapsMarkerClusterer>
```

## Open-state animation

The overlay sets `**data-state="open"**` on its content wrapper while visible. Pass a class to the component to target that wrapper and animate its entrance:

```vue
<ScriptGoogleMapsOverlayView v-model:open="open" class="popup">
  <div>
    Animated popup
  </div>
</ScriptGoogleMapsOverlayView>

<style>
.popup[data-state="open"] {
  animation: fadeIn 200ms ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
</style>
```

Closing sets the anchor to `**visibility: hidden**` immediately; the component does not wait for `**transitionend**` or `**animationend**`, so CSS exit animations are not visible. A template ref exposes `**dataState**` for code that needs the current state, but it is not a slot prop.

The `**blockMapInteraction**` prop (default `**true**`) calls `**google.maps.OverlayView.preventMapHitsAndGesturesFrom()**` to stop clicks, taps, and drags from propagating through the overlay to the map. Set it to `**false**` for non-interactive overlays like labels.

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

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

[**\<ScriptGoogleMaps>** Lazy-load an interactive Google map and compose it with declarative child components.](https://scripts.nuxt.com/scripts/google-maps/api/script-google-maps) [**useScriptGoogleMaps()** Load the Google Maps SDK and access its API directly from a composable.](https://scripts.nuxt.com/scripts/google-maps/api/use-script-google-maps)

**On this page **

- [Marker Anchoring](#marker-anchoring)
- [Controlled vs Uncontrolled Open State](#controlled-vs-uncontrolled-open-state)
- [Popup on Marker Click](#popup-on-marker-click)
- [Persistent Label](#persistent-label)
- [Position Format](#position-format)
- [Map Panning](#map-panning)
- [Cluster Awareness](#cluster-awareness)
- [Open-state animation](#open-state-animation)

```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/overlay-view#webpage","@type":"WebPage","description":"Position custom Vue content over a Google map or marker.","name":"<ScriptGoogleMapsOverlayView>","url":"https://scripts.nuxt.com/scripts/google-maps/api/overlay-view","breadcrumb":{"@id":"https://scripts.nuxt.com/scripts/google-maps/api/overlay-view#breadcrumb"},"isPartOf":{"@id":"https://scripts.nuxt.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://scripts.nuxt.com/scripts/google-maps/api/overlay-view"]}],"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/overlay-view#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":"<ScriptGoogleMapsOverlayView>","item":"https://scripts.nuxt.com/scripts/google-maps/api/overlay-view","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.
