Advanced Markers

AdvancedMarkerElement class

google.maps.marker.AdvancedMarkerElement class

Shows a position on a map. Note that the position must be set for the AdvancedMarkerElement 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 extends HTMLElement.

This class implements AdvancedMarkerElementOptions.

Access by calling const {AdvancedMarkerElement} = await google.maps.importLibrary("marker").
See Libraries in the Maps JavaScript API.

AdvancedMarkerElement
AdvancedMarkerElement([options])
Parameters: 
Creates an AdvancedMarkerElement with the options specified. If a map is specified, the AdvancedMarkerElement is added to the map upon construction.
anchorLeft
Type:  string optional
A CSS 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. The default value is "-%50".
HTML attribute:
  • <gmp-advanced-marker anchor-left="string"></gmp-advanced-marker>
anchorTop
Type:  string optional
A CSS 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. The default value is "-%100".
HTML attribute:
  • <gmp-advanced-marker anchor-top="string"></gmp-advanced-marker>
collisionBehavior
Type:  CollisionBehavior optional
gmpClickable
Type:  boolean optional
HTML attribute:
  • <gmp-advanced-marker gmp-clickable></gmp-advanced-marker>
gmpDraggable
Type:  boolean optional
map
Type:  Map optional
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:  number optional
element
Type:  HTMLElement
This field is read-only. The DOM Element backing the view.
content
Type:  Node optional
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|AddEventListenerOptions optional See options. Custom events only support capture and passive.
Return Value:  void
Sets up a function that will be called whenever the specified event is delivered to the target. See addEventListener
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. See removeEventListener.
click
function(event)
Arguments: 
This event is fired when the AdvancedMarkerElement element is clicked.

Not available with addEventListener() (use gmp-click instead).
drag
function(event)
Arguments: 
This event is repeatedly fired while the user drags the AdvancedMarkerElement.

Not available with addEventListener().
dragend
function(event)
Arguments: 
This event is fired when the user stops dragging the AdvancedMarkerElement.

Not available with addEventListener().
dragstart
function(event)
Arguments: 
This event is fired when the user starts dragging the AdvancedMarkerElement.

Not available with addEventListener().
Betagmp-click