Places UI Kit: A ready-to-use library that provides room for customization and low-code development. Try it out, and share yourinput on your UI Kit experience.

Advanced Markers

AdvancedMarkerElementclass

google.maps.marker.AdvancedMarkerElementclass

Shows a position on a map. Note that theposition must be set for theAdvancedMarkerElement to display.

Custom element:
<gmp-advanced-marker anchor-left="string" anchor-top="string" gmp-clickable position="lat,lng" title="string"></gmp-advanced-marker>

This class extendsHTMLElement.

This class implementsAdvancedMarkerElementOptions.

Access by callingconst {AdvancedMarkerElement} = await google.maps.importLibrary("marker").
SeeLibraries in the Maps JavaScript API.

Constructor

AdvancedMarkerElement
AdvancedMarkerElement([options])
Parameters: 
Creates anAdvancedMarkerElement with the options specified. If a map is specified, theAdvancedMarkerElement is added to the map upon construction.

Properties

anchorLeft
Type: stringoptional
Default: "-50%"
ACSS length-percentage value which is used to offset the anchor point of the marker from the top left corner of the marker. This is useful when using a visual which has an anchor point that is different than the typical bottom center point of the default marker.
HTML attribute:
  • <gmp-advanced-marker anchor-left="string"></gmp-advanced-marker>
anchorTop
Type: stringoptional
Default: "-100%"
ACSS length-percentage value which is used to offset the anchor point of the marker from the top left corner of the marker. This is useful when using a visual which has an anchor point that is different than the typical bottom center point of the default marker.
HTML attribute:
  • <gmp-advanced-marker anchor-top="string"></gmp-advanced-marker>
collisionBehavior
Type: CollisionBehavioroptional
gmpClickable
Type: booleanoptional
HTML attribute:
  • <gmp-advanced-marker gmp-clickable></gmp-advanced-marker>
gmpDraggable
Type: booleanoptional
map
Type: Mapoptional
position
HTML attribute:
  • <gmp-advanced-marker position="lat,lng"></gmp-advanced-marker>
  • <gmp-advanced-marker position="lat,lng,altitude"></gmp-advanced-marker>
title
Type: string
HTML attribute:
  • <gmp-advanced-marker title="string"></gmp-advanced-marker>
zIndex
Type: numberoptional
element

Deprecated: Use the AdvancedMarkerElement directly.

This field is read-only. The DOM Element backing the view.
content

Deprecated: Use.children instead.

Type: Nodeoptional

Methods

addEventListener
addEventListener(type, listener[, options])
Parameters: 
  • typestring A case-sensitive string representing the event type to listen for.
  • listenerEventListener|EventListenerObject The object that receives a notification. This must be a function or an object with the handleEvent method
  • optionsboolean|AddEventListenerOptionsoptional Seeoptions. Custom events only supportcapture andpassive.
Return Value: void
Sets up a function that will be called whenever the specified event is delivered to the target. SeeaddEventListener
addListener
addListener(eventName, handler)
Parameters: 
  • eventNamestring Observed event.
  • handlerFunction Function to handle events.
Return Value: MapsEventListener Resulting event listener.
Adds the given listener function to the given event name in the Maps Eventing system.
removeEventListener
removeEventListener(type, listener[, options])
Parameters: 
Return Value: void
Removes an event listener previously registered with addEventListener from the target. SeeremoveEventListener.

Events

click
function(event)
Arguments: 
This event is fired when theAdvancedMarkerElement element is clicked.

Not available withaddEventListener() (usegmp-click instead).
drag
function(event)
Arguments: 
This event is repeatedly fired while the user drags theAdvancedMarkerElement.

Not available withaddEventListener().
dragend
function(event)
Arguments: 
This event is fired when the user stops dragging theAdvancedMarkerElement.

Not available withaddEventListener().
dragstart
function(event)
Arguments: 
This event is fired when the user starts dragging theAdvancedMarkerElement.

Not available withaddEventListener().
gmp-click
function(event)
Arguments: 
This event is fired when theAdvancedMarkerElement element is clicked. Best used withaddEventListener() (instead ofaddListener()).

AdvancedMarkerElementOptionsinterface

google.maps.marker.AdvancedMarkerElementOptionsinterface

Options for constructing anAdvancedMarkerElement.

Properties

anchorLeftoptional
Type: stringoptional
Default: "-50%"
ACSS length-percentage value which is used to offset the anchor point of the marker from the top left corner of the marker. This is useful when using a visual which has an anchor point that is different than the typical bottom center point of the default marker.
anchorTopoptional
Type: stringoptional
Default: "-100%"
ACSS length-percentage value which is used to offset the anchor point of the marker from the top left corner of the marker. This is useful when using a visual which has an anchor point that is different than the typical bottom center point of the default marker.
collisionBehavioroptional
Type: CollisionBehavioroptional
An enumeration specifying how anAdvancedMarkerElement should behave when it collides with anotherAdvancedMarkerElement or with the basemap labels on a vector map.

Note:AdvancedMarkerElement toAdvancedMarkerElement collision works on both raster and vector maps, however,AdvancedMarkerElement to base map's label collision only works on vector maps.

contentoptional
Type: Nodeoptional
Default:PinElement
The DOM Element backing the visual of anAdvancedMarkerElement.

Note:AdvancedMarkerElement does not clone the passed-in DOM element. Once the DOM element is passed to anAdvancedMarkerElement, passing the same DOM element to anotherAdvancedMarkerElement will move the DOM element and cause the previousAdvancedMarkerElement to look empty.

gmpClickableoptional
Type: booleanoptional
Default:false
Iftrue, theAdvancedMarkerElement will be clickable and trigger thegmp-click event, and will be interactive for accessibility purposes (e.g. allowing keyboard navigation via arrow keys).
gmpDraggableoptional
Type: booleanoptional
Default:false
Iftrue, theAdvancedMarkerElement can be dragged.

Note:AdvancedMarkerElement with altitude is not draggable.

mapoptional
Type: Mapoptional
Map on which to display theAdvancedMarkerElement. The map is required to display theAdvancedMarkerElement and can be provided by settingAdvancedMarkerElement.map if not provided at the construction.
positionoptional
Sets theAdvancedMarkerElement's position. AnAdvancedMarkerElement may be constructed without a position, but will not be displayed until its position is provided - for example, by a user's actions or choices. AnAdvancedMarkerElement's position can be provided by settingAdvancedMarkerElement.position if not provided at the construction.

Note:AdvancedMarkerElement with altitude is only supported on vector maps.

titleoptional
Type: stringoptional
Rollover text. If provided, an accessibility text (e.g. for use with screen readers) will be added to theAdvancedMarkerElement with the provided value.
zIndexoptional
Type: numberoptional
AllAdvancedMarkerElements are displayed on the map in order of their zIndex, with higher values displaying in front ofAdvancedMarkerElements with lower values. By default,AdvancedMarkerElements are displayed according to their vertical position on screen, with lowerAdvancedMarkerElements appearing in front ofAdvancedMarkerElements farther up the screen. Note thatzIndex is also used to help determine relative priority betweenCollisionBehavior.OPTIONAL_AND_HIDES_LOWER_PRIORITY Advanced Markers. A higherzIndex value indicates higher priority.

AdvancedMarkerClickEventclass

google.maps.marker.AdvancedMarkerClickEventclass

This event is created from clicking an Advanced Marker. Access the marker's position withevent.target.position.

This class extendsEvent.

Access by callingconst {AdvancedMarkerClickEvent} = await google.maps.importLibrary("marker").
SeeLibraries in the Maps JavaScript API.

PinElementclass

google.maps.marker.PinElementclass

APinElement represents a DOM element that consists of a shape and a glyph. The shape has the same balloon style as seen in the defaultAdvancedMarkerElement orMarker3DElement. The glyph is an optional DOM element displayed in the balloon shape. APinElement may have a different aspect ratio depending on itsPinElement.scale.

This class extendsHTMLElement.

This class implementsPinElementOptions.

Access by callingconst {PinElement} = await google.maps.importLibrary("marker").
SeeLibraries in the Maps JavaScript API.

Constructor

PinElement
PinElement([options])
Parameters: 

Properties

background
Type: stringoptional
borderColor
Type: stringoptional
glyphColor
Type: stringoptional
glyphSrc
Type: URL|stringoptional
glyphText
Type: stringoptional
scale
Type: numberoptional
element

Deprecated: Use the PinElement directly.

This field is read-only. The DOM Element backing the view.
glyph

Deprecated: UsePinElementOptions.glyphText orPinElementOptions.glyphSrc instead.

Type: string|Element|URLoptional

Methods

addEventListener
addEventListener(type, listener[, options])
Parameters: 
  • typestring A case-sensitive string representing the event type to listen for.
  • listenerEventListener|EventListenerObject The object that receives a notification. This must be a function or an object with the handleEvent method
  • optionsboolean|AddEventListenerOptionsoptional Seeoptions. Custom events only supportcapture andpassive.
Return Value: void
Sets up a function that will be called whenever the specified event is delivered to the target. SeeaddEventListener.
removeEventListener
removeEventListener(type, listener[, options])
Parameters: 
Return Value: void
Removes an event listener previously registered with addEventListener from the target. SeeremoveEventListener.

PinElementOptionsinterface

google.maps.marker.PinElementOptionsinterface

Options for creating aPinElement.

Properties

backgroundoptional
Type: stringoptional
The background color of the pin shape. Supports any CSScolor value.
borderColoroptional
Type: stringoptional
The border color of the pin shape. Supports any CSScolor value.
glyphoptional

Deprecated: UsePinElementOptions.glyphText orPinElementOptions.glyphSrc instead.

Type: string|Element|URLoptional
The DOM element displayed in the pin.
glyphColoroptional
Type: stringoptional
The color of the glyph. Supports any CSScolor value.
glyphSrcoptional
Type: URL|stringoptional
The source of the glyph image to be displayed in the pin.
glyphTextoptional
Type: stringoptional
The text displayed in the pin.
scaleoptional
Type: numberoptional
Default:1
The scale of the pin.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-18 UTC.