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.

Marker (legacy)

Markerclass

google.maps.Markerclass

Deprecated: As of February 21st, 2024, google.maps.Marker is deprecated. Please useAdvancedMarkerElement instead. At this time, google.maps.Marker is not scheduled to be discontinued, butAdvancedMarkerElement is recommended over google.maps.Marker. While google.maps.Marker will continue to receive bug fixes for any major regressions, existing bugs in google.maps.Marker will not be addressed. At least 12 months notice will be given before support is discontinued. Please seehttps://developers.google.com/maps/deprecations for additional details andhttps://developers.google.com/maps/documentation/javascript/advanced-markers/migration for the migration guide.

This class extendsMVCObject.

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

Constructor

Marker
Marker([opts])
Parameters: 
Creates a marker with the options specified. If a map is specified, the marker is added to the map upon construction. Note that the position must be set for the marker to display.

Constants

MAX_ZINDEXThe maximum default z-index that the API will assign to a marker. You may set a higher z-index to bring a marker to the front.

Methods

getAnimation
getAnimation()
Parameters:  None
Return Value: Animation|null|undefined
Get the currently running animation.
getClickable
getClickable()
Parameters:  None
Return Value: boolean True if the Marker is clickable.
Get the clickable status of theMarker.
getCursor
getCursor()
Parameters:  None
Return Value: string|null|undefined
Get the mouse cursor type shown on hover.
getDraggable
getDraggable()
Parameters:  None
Return Value: boolean True if the Marker is draggable.
Get the draggable status of theMarker.
getIcon
getIcon()
Parameters:  None
Return Value: string|Icon|Symbol|null|undefined
Get the icon of theMarker. SeeMarkerOptions.icon.
getLabel
getLabel()
Parameters:  None
Return Value: MarkerLabel|string|null|undefined
Get the label of theMarker. SeeMarkerOptions.label.
getMap
getMap()
Parameters:  None
Return Value: Map|StreetViewPanorama
Get the map or panaroama theMarker is rendered on.
getOpacity
getOpacity()
Parameters:  None
Return Value: number|null|undefined A number between 0.0 and 1.0.
Get the opacity of theMarker.
getPosition
getPosition()
Parameters:  None
Return Value: LatLng|null|undefined
Get the position of theMarker.
getShape
getShape()
Parameters:  None
Return Value: MarkerShape|null|undefined
Get the shape of theMarker used for interaction. SeeMarkerOptions.shape andMarkerShape.
getTitle
getTitle()
Parameters:  None
Return Value: string|null|undefined
Get the title of theMarker tooltip. SeeMarkerOptions.title.
getVisible
getVisible()
Parameters:  None
Return Value: boolean True if the Marker is visible.
Get the visibility of theMarker.
getZIndex
getZIndex()
Parameters:  None
Return Value: number|null|undefined zIndex of the Marker.
Get the zIndex of theMarker. SeeMarkerOptions.zIndex.
setAnimation
setAnimation([animation])
Parameters: 
  • animationAnimationoptional The animation to play.
Return Value:  None
Start an animation. Any ongoing animation will be cancelled. Currently supported animations are:Animation.BOUNCE,Animation.DROP. Passing innull will cause any animation to stop.
setClickable
setClickable(flag)
Parameters: 
  • flagboolean Iftrue, the Marker can be clicked.
Return Value:  None
Set if theMarker is clickable.
setCursor
setCursor([cursor])
Parameters: 
  • cursorstringoptional Mouse cursor type.
Return Value:  None
Set the mouse cursor type shown on hover.
setDraggable
setDraggable(flag)
Parameters: 
  • flagbooleanoptional Iftrue, the Marker can be dragged.
Return Value:  None
Set if theMarker is draggable.
setIcon
setIcon([icon])
Parameters: 
Return Value:  None
Set the icon for theMarker. SeeMarkerOptions.icon.
setLabel
setLabel([label])
Parameters: 
Return Value:  None
Set the label for theMarker. SeeMarkerOptions.label.
setMap
setMap(map)
Parameters: 
Return Value:  None
Renders theMarker on the specified map or panorama. If map is set tonull, the marker will be removed.
setOpacity
setOpacity([opacity])
Parameters: 
  • opacitynumberoptional A number between 0.0, transparent, and 1.0, opaque.
Return Value:  None
Set the opacity of theMarker.
setOptions
setOptions(options)
Parameters: 
Return Value:  None
Set the options for theMarker.
setPosition
setPosition([latlng])
Parameters: 
Return Value:  None
Set the postition for theMarker.
setShape
setShape([shape])
Parameters: 
Return Value:  None
Set the shape of theMarker used for interaction. SeeMarkerOptions.shape andMarkerShape.
setTitle
setTitle([title])
Parameters: 
  • titlestringoptional
Return Value:  None
Set the title of theMarker tooltip. SeeMarkerOptions.title.
setVisible
setVisible(visible)
Parameters: 
  • visibleboolean Iftrue, the Marker is visible
Return Value:  None
Set if theMarker is visible.
setZIndex
setZIndex([zIndex])
Parameters: 
  • zIndexnumberoptional
Return Value:  None
Set the zIndex of theMarker. SeeMarkerOptions.zIndex.
Inherited:addListener,bindTo,get,notify,set,setValues,unbind,unbindAll

Events

animation_changed
function()
Arguments:  None
This event is fired when theMarker animation property changes.
click
function(event)
Arguments: 
This event is fired when theMarker icon was clicked.
clickable_changed
function()
Arguments:  None
This event is fired when theMarker clickable property changes.
contextmenu
function(event)
Arguments: 
This event is fired when the DOM contextmenu event is fired on theMarker
cursor_changed
function()
Arguments:  None
This event is fired when theMarker cursor property changes.
dblclick
function(event)
Arguments: 
This event is fired when theMarker icon was double clicked.
drag
function(event)
Arguments: 
This event is repeatedly fired while the user drags theMarker.
dragend
function(event)
Arguments: 
This event is fired when the user stops dragging theMarker.
draggable_changed
function()
Arguments:  None
This event is fired when theMarker draggable property changes.
dragstart
function(event)
Arguments: 
This event is fired when the user starts dragging theMarker.
flat_changed
function()
Arguments:  None
This event is fired when theMarker flat property changes.
icon_changed
function()
Arguments:  None
This event is fired when theMarker icon property changes.
mousedown
function(event)
Arguments: 
This event is fired for a mousedown on theMarker.
mouseout
function(event)
Arguments: 
This event is fired when the mouse leaves the area of theMarker icon.
mouseover
function(event)
Arguments: 
This event is fired when the mouse enters the area of theMarker icon.
mouseup
function(event)
Arguments: 
This event is fired for a mouseup on theMarker.
position_changed
function()
Arguments:  None
This event is fired when theMarker position property changes.
shape_changed
function()
Arguments:  None
This event is fired when theMarker shape property changes.
title_changed
function()
Arguments:  None
This event is fired when theMarker title property changes.
visible_changed
function()
Arguments:  None
This event is fired when theMarker visible property changes.
zindex_changed
function()
Arguments:  None
This event is fired when theMarker zIndex property changes.
rightclick

Deprecated: Use theMarker.contextmenu event instead in order to support usage patterns like control-click on macOS.

function(event)
Arguments: 
This event is fired for a rightclick on theMarker.

MarkerOptionsinterface

google.maps.MarkerOptionsinterface

Deprecated: As of February 21st, 2024, google.maps.Marker is deprecated. Please use google.maps.marker.AdvancedMarkerElement instead. Please seehttps://developers.google.com/maps/deprecations for deprecation details andhttps://developers.google.com/maps/documentation/javascript/advanced-markers/migration for the migration guide.

MarkerOptions object used to define the properties that can be set on a Marker.

Properties

anchorPointoptional
Type: Pointoptional
The offset from the marker's position to the tip of an InfoWindow that has been opened with the marker as anchor.
animationoptional
Type: Animationoptional
Default:null
Which animation to play when marker is added to a map.
clickableoptional
Type: booleanoptional
Default:true
Iftrue, the marker receives mouse and touch events.
BetacollisionBehavioroptional

Deprecated:collisionBehavior is deprecated as of July 2023. UseAdvancedMarkerElement.collisionBehavior instead.

Notice: Available only in thev=beta channel.

Type: string|CollisionBehavioroptional
Default:null
Set a collision behavior for markers on vector maps.
crossOnDragoptional
Type: booleanoptional
Default:true
Iffalse, disables cross that appears beneath the marker when dragging.
cursoroptional
Type: stringoptional
Default:pointer
Mouse cursor type to show on hover.
draggableoptional
Type: booleanoptional
Default:false
Iftrue, the marker can be dragged.Note: Setting this totrue will make the marker clickable even ifclickable is set tofalse.
iconoptional
Type: string|Icon|Symboloptional
Icon for the foreground. If a string is provided, it is treated as though it were anIcon with the string asurl.
labeloptional
Type: string|MarkerLabeloptional
Default:null
Adds a label to the marker. A marker label is a letter or number that appears inside a marker. The label can either be a string, or aMarkerLabel object. If provided andMarkerOptions.title is not provided, an accessibility text (e.g. for use with screen readers) will be added to the marker with the provided label's text. Please note that thelabel is currently only used for accessibility text for non-optimized markers.
mapoptional
Type: Map|StreetViewPanoramaoptional
Map on which to display Marker. The map is required to display the marker and can be provided withMarker.setMap if not provided at marker construction.
opacityoptional
Type: numberoptional
Default: 1.0
A number between 0.0, transparent, and 1.0, opaque.
optimizedoptional
Type: booleanoptional
Optimization enhances performance by rendering many markers as a single static element. This is useful in cases where a large number of markers is required. Read more aboutmarker optimization.Note: This optimization has no effect for markers on vector maps.
positionoptional
Type: LatLng|LatLngLiteraloptional
Sets the marker position. A marker may be constructed but not displayed until its position is provided - for example, by a user's actions or choices. A marker position can be provided withMarker.setPosition if not provided at marker construction.
shapeoptional
Type: MarkerShapeoptional
Image map region definition used for drag/click.
titleoptional
Type: stringoptional
Default:undefined
Rollover text. If provided, an accessibility text (e.g. for use with screen readers) will be added to the marker with the provided value. Please note that thetitle is currently only used for accessibility text for non-optimized markers.
visibleoptional
Type: booleanoptional
Default:true
Iftrue, the marker is visible.
zIndexoptional
Type: numberoptional
All markers are displayed on the map in order of their zIndex, with higher values displaying in front of markers with lower values. By default, markers are displayed according to their vertical position on screen, with lower markers appearing in front of markers further up the screen.

CollisionBehaviorconstants

google.maps.CollisionBehaviorconstants

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

Constants

OPTIONAL_AND_HIDES_LOWER_PRIORITYDisplay the marker only if it does not overlap with other markers. If two markers of this type would overlap, the one with the higher zIndex is shown. If they have the same zIndex, the one with the lower vertical screen position is shown.
REQUIREDAlways display the marker regardless of collision. This is the default behavior.
REQUIRED_AND_HIDES_OPTIONALAlways display the marker regardless of collision, and hide any OPTIONAL_AND_HIDES_LOWER_PRIORITY markers or labels that would overlap with the marker.

Iconinterface

google.maps.Iconinterface

A structure representing a Marker icon image.

Properties

url
Type: string
The URL of the image or sprite sheet.
anchoroptional
Type: Pointoptional
The position at which to anchor an image in correspondence to the location of the marker on the map. By default, the anchor is located along the center point of the bottom of the image.
labelOriginoptional
Type: Pointoptional
The origin of the label relative to the top-left corner of the icon image, if a label is supplied by the marker. By default, the origin is located in the center point of the image.
originoptional
Type: Pointoptional
The position of the image within a sprite, if any. By default, the origin is located at the top left corner of the image(0, 0).
scaledSizeoptional
Type: Sizeoptional
The size of the entire image after scaling, if any. Use this property to stretch/shrink an image or a sprite.
sizeoptional
Type: Sizeoptional
The display size of the sprite or image. When using sprites, you must specify the sprite size. If the size is not provided, it will be set when the image loads.

MarkerLabelinterface

google.maps.MarkerLabelinterface

These options specify the appearance of a marker label. A marker label is a string (often a single character) which will appear inside the marker. If you are using it with a custom marker, you can reposition it with thelabelOrigin property in theIcon class.

Properties

text
Type: string
The text to be displayed in the label.
classNameoptional
Type: stringoptional
Default:'' (empty string)
The className property of the label's element (equivalent to the element's class attribute). Multiple space-separated CSS classes can be added. The font color, size, weight, and family can only be set via the other properties ofMarkerLabel. CSS classes should not be used to change the position nor orientation of the label (e.g. using translations and rotations) if also usingmarker collision management.
coloroptional
Type: stringoptional
Default:'black'
The color of the label text.
fontFamilyoptional
Type: stringoptional
The font family of the label text (equivalent to the CSS font-family property).
fontSizeoptional
Type: stringoptional
Default:'14px'
The font size of the label text (equivalent to the CSS font-size property).
fontWeightoptional
Type: stringoptional
The font weight of the label text (equivalent to the CSS font-weight property).

MarkerShapeinterface

google.maps.MarkerShapeinterface

This object defines the clickable region of a marker image. The shape consists of two properties —type andcoord — which define the non-transparent region of an image.

Properties

type
Type: string
Describes the shape's type and can becircle,poly orrect.
coordsoptional
Type: Array<number>optional
The format of this attribute depends on the value of thetype and follows the w3 AREAcoords specification found at http://www.w3.org/TR/REC-html40/struct/objects.html#adef-coords.
Thecoords attribute is an array of integers that specify the pixel position of the shape relative to the top-left corner of the target image. The coordinates depend on the value oftype as follows:
  -circle: coords is[x1,y1,r] where x1,y2 are the coordinates of the center of the circle, and r is the radius of the circle.
  -poly: coords is[x1,y1,x2,y2...xn,yn] where each x,y pair contains the coordinates of one vertex of the polygon.
  -rect: coords is[x1,y1,x2,y2] where x1,y1 are the coordinates of the upper-left corner of the rectangle and x2,y2 are the coordinates of the lower-right coordinates of the rectangle.

Symbolinterface

google.maps.Symbolinterface

Describes a symbol, which consists of a vector path with styling. A symbol can be used as the icon of a marker, or placed on a polyline.

Properties

path
Type: SymbolPath|string
The symbol's path, which is a built-in symbol path, or a custom path expressed usingSVG path notation. Required.
anchoroptional
Type: Pointoptional
Default:google.maps.Point(0,0)
The position of the symbol relative to the marker or polyline. The coordinates of the symbol's path are translated left and up by the anchor's x and y coordinates respectively. The position is expressed in the same coordinate system as the symbol's path.
fillColoroptional
Type: stringoptional
The symbol's fill color. All CSS3 colors are supported except for extended named colors. For symbol markers, this defaults to 'black'. For symbols on polylines, this defaults to the stroke color of the corresponding polyline.
fillOpacityoptional
Type: numberoptional
Default:0
The symbol's fill opacity.
labelOriginoptional
Type: Pointoptional
Default:google.maps.Point(0,0)
The origin of the label relative to the origin of the path, if label is supplied by the marker. The origin is expressed in the same coordinate system as the symbol's path. This property is unused for symbols on polylines.
rotationoptional
Type: numberoptional
Default:0
The angle by which to rotate the symbol, expressed clockwise in degrees. A symbol in anIconSequence wherefixedRotation isfalse is rotated relative to the angle of the edge on which it lies.
scaleoptional
Type: numberoptional
The amount by which the symbol is scaled in size. For symbol markers, this defaults to 1; after scaling, the symbol may be of any size. For symbols on a polyline, this defaults to the stroke weight of the polyline; after scaling, the symbol must lie inside a square 22 pixels in size centered at the symbol's anchor.
strokeColoroptional
Type: stringoptional
The symbol's stroke color. All CSS3 colors are supported except for extended named colors. For symbol markers, this defaults to 'black'. For symbols on a polyline, this defaults to the stroke color of the polyline.
strokeOpacityoptional
Type: numberoptional
The symbol's stroke opacity. For symbol markers, this defaults to 1. For symbols on a polyline, this defaults to the stroke opacity of the polyline.
strokeWeightoptional
Type: numberoptional
Default: TheSymbol.scale of the symbol.
The symbol's stroke weight.

SymbolPathconstants

google.maps.SymbolPathconstants

Built-in symbol paths.

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

Constants

BACKWARD_CLOSED_ARROWA backward-pointing closed arrow.
BACKWARD_OPEN_ARROWA backward-pointing open arrow.
CIRCLEA circle.
FORWARD_CLOSED_ARROWA forward-pointing closed arrow.
FORWARD_OPEN_ARROWA forward-pointing open arrow.

Animationconstants

google.maps.Animationconstants

Animations that can be played on a marker. Use theMarker.setAnimation method on Marker or theMarkerOptions.animation option to play an animation.

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

Constants

BOUNCEMarker bounces until animation is stopped by callingMarker.setAnimation withnull.
DROPMarker drops from the top of the map to its final location. Animation will cease once the marker comes to rest andMarker.getAnimation will returnnull. This type of animation is usually specified during creation of the marker.

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-10-10 UTC.