Skip to main content

Marker

GmvMarker wraps google.maps.marker.AdvancedMarkerElement. It uses google.maps.importLibrary("marker"), so document and configure it as an Advanced Marker, not as legacy google.maps.Marker.

The component is exported as Marker from @gmap-vue/v3/components and registered by the plugin as GmvMarker.

Props

Marker props interface
export interface MarkerProps {
collisionBehavior?: google.maps.CollisionBehavior;
content?: HTMLElement;
gmpClickable?: boolean;
gmpDraggable?: boolean;
position?:
| google.maps.LatLng
| google.maps.LatLngLiteral
| google.maps.LatLngAltitude
| google.maps.LatLngAltitudeLiteral;
title?: string;
zIndex?: number;
markerKey?: string;
clusterKey?: string;
mapKey?: string;
options?: Record<string, unknown>;
}
PropTypeDefaultDescription
collisionBehaviorgoogle.maps.CollisionBehaviorundefinedAdvanced Marker collision behavior.
contentHTMLElementundefinedDOM content passed to the Advanced Marker options. Verify mount timing when passing Vue-owned elements.
gmpClickablebooleantrueEnables Advanced Marker click behavior. This is part of the Google Advanced Marker beta surface.
gmpDraggablebooleanfalseEnables marker dragging.
positiongoogle.maps.LatLng | google.maps.LatLngLiteral | google.maps.LatLngAltitude | google.maps.LatLngAltitudeLiteralundefinedMarker position.
titlestringundefinedAccessibility text and hover title.
zIndexnumberundefinedMarker stacking order.
markerKeystringundefinedPromise key used by useMarkerPromise(key).
clusterKeystringundefinedCluster promise key used when adding the marker to a specific cluster.
mapKeystringundefinedMap promise key used when the marker is not a direct descendant of GmvMap.
optionsRecord<string, unknown>undefinedFallback for Google Advanced Marker options not yet represented by explicit props.

Map and cluster resolution

When mapKey is provided, the component injects that map promise. Without mapKey, it finds the parent GmvMap instance.

When clusterKey is provided, the component uses that cluster promise. Without clusterKey, it can find a parent GmvCluster. Clustered markers are created without a map and are added to the clusterer.

Events

EventPayloadDescription
clickgoogle.maps.MapMouseEventStandard marker click event.
draggoogle.maps.MapMouseEventFired while dragging.
dragstartgoogle.maps.MapMouseEventFired when dragging starts.
dragendgoogle.maps.MapMouseEventFired when dragging ends.
gmp-clickgoogle.maps.marker.AdvancedMarkerClickEventAdvanced Marker click event.
update:position{ lat?: number; lng?: number }Fired after dragend with the marker's current position.

Exposed properties

PropertyTypeDescription
markerPromisePromise<google.maps.marker.AdvancedMarkerElement | undefined>Resolves to the underlying Advanced Marker instance.
VNodeMarkerIconVNode | undefinedInternal vnode used when marker content participates in parent-child component behavior.
<script setup lang="ts">
import { Marker } from "@gmap-vue/v3/components";
import { ref } from "vue";

const markerRef = ref<InstanceType<typeof Marker> | null>(null);

async function readMarker() {
const marker = await markerRef.value?.markerPromise;
console.log(marker?.position);
}
</script>

<template>
<GmvMap
:center="{ lat: -34.6037, lng: -58.3816 }"
:zoom="13"
style="width: 100%; height: 500px"
>
<GmvMarker
ref="markerRef"
:position="{ lat: -34.6037, lng: -58.3816 }"
title="Marker"
/>
</GmvMap>

<button @click="readMarker">Read marker</button>
</template>