Advanced Markers Stay organized with collections Save and categorize content based on your preferences.
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 an AdvancedMarkerElement with the options specified. If a map is specified, theAdvancedMarkerElement is added to the map upon construction. |
Properties | |
|---|---|
anchorLeft | Type: stringoptionalDefault: "-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:
|
anchorTop | Type: stringoptionalDefault: "-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:
|
collisionBehavior | Type: CollisionBehavioroptional |
gmpClickable | Type: booleanoptionalHTML attribute:
|
gmpDraggable | Type: booleanoptional |
map | Type: Mapoptional |
position | Type: LatLng|LatLngLiteral|LatLngAltitude|LatLngAltitudeLiteraloptionalHTML attribute:
|
title | Type: stringHTML attribute:
|
zIndex | Type: numberoptional |
| Deprecated: Use the AdvancedMarkerElement directly. Type: HTMLElementThis field is read-only. The DOM Element backing the view. |
| Deprecated: Use.children instead. Type: Nodeoptional |
Methods | |
|---|---|
addEventListener | addEventListener(type, listener[, options])Parameters:
Return Value: voidSets up a function that will be called whenever the specified event is delivered to the target. SeeaddEventListener |
addListener | addListener(eventName, handler)Parameters:
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: voidRemoves an event listener previously registered with addEventListener from the target. SeeremoveEventListener. |
Events | |
|---|---|
click | function(event)Arguments:
This event is fired when the AdvancedMarkerElement element is clicked.Not available with addEventListener() (usegmp-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(). |
gmp-click | function(event)Arguments:
This event is fired when the AdvancedMarkerElement element is clicked. Best used withaddEventListener() (instead ofaddListener()). |
AdvancedMarkerElementOptionsinterface
google.maps.marker.AdvancedMarkerElementOptionsinterface
Options for constructing anAdvancedMarkerElement.
Properties | |
|---|---|
anchorLeftoptional | Type: stringoptionalDefault: "-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: stringoptionalDefault: "-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: CollisionBehavioroptionalAn enumeration specifying how an AdvancedMarkerElement should behave when it collides with anotherAdvancedMarkerElement or with the basemap labels on a vector map.Note: |
contentoptional | Type: NodeoptionalDefault: PinElementThe DOM Element backing the visual of an AdvancedMarkerElement.Note: |
gmpClickableoptional | Type: booleanoptionalDefault: falseIf true, 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: booleanoptionalDefault: falseIf true, theAdvancedMarkerElement can be dragged.Note: |
mapoptional | Type: MapoptionalMap on which to display the AdvancedMarkerElement. The map is required to display theAdvancedMarkerElement and can be provided by settingAdvancedMarkerElement.map if not provided at the construction. |
positionoptional | Type: LatLng|LatLngLiteral|LatLngAltitude|LatLngAltitudeLiteraloptionalSets the AdvancedMarkerElement'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: |
titleoptional | Type: stringoptionalRollover text. If provided, an accessibility text (e.g. for use with screen readers) will be added to the AdvancedMarkerElement with the provided value. |
zIndexoptional | Type: numberoptionalAll AdvancedMarkerElements 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:
|
Methods | |
|---|---|
addEventListener | addEventListener(type, listener[, options])Parameters:
Return Value: voidSets 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: voidRemoves an event listener previously registered with addEventListener from the target. SeeremoveEventListener. |
PinElementOptionsinterface
google.maps.marker.PinElementOptionsinterface
Options for creating aPinElement.
Properties | |
|---|---|
backgroundoptional | Type: stringoptionalThe background color of the pin shape. Supports any CSScolor value. |
borderColoroptional | Type: stringoptionalThe border color of the pin shape. Supports any CSScolor value. |
| Deprecated: Use The DOM element displayed in the pin. |
glyphColoroptional | Type: stringoptionalThe color of the glyph. Supports any CSScolor value. |
glyphSrcoptional | Type: URL|stringoptionalThe source of the glyph image to be displayed in the pin. |
glyphTextoptional | Type: stringoptionalThe text displayed in the pin. |
scaleoptional | Type: numberoptionalDefault: 1The 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.