A special marker class for data from the Google Maps Places API. Uses the recommended colors and icons from a place result.

Hierarchy (View Summary)

  • Marker<google.maps.places.PlaceResult>
    • PlaceMarker

Constructors

Properties

attributeDefaults_: Partial<Attributes<PlaceResult>> = {}

Attributes set by inheriting classes. These are applied at a lower precedence than the values in attributes_ and allow inheriting classes to provide values that can be overridden by the user and restored to their original value.

backgroundColor?: AttributeValue<PlaceResult, string>

The background-color for the marker pin. Can be specified in any format supported by CSS.

borderColor?: AttributeValue<PlaceResult, string>

The border-color for the marker pin. Can be specified in any format supported by CSS.

classList?: AttributeValue<PlaceResult, string | string[]>

A single classname or list of class names to be added to the content element.

collisionBehavior?: AttributeValue<PlaceResult, CollisionBehavior>

The collision behavior controls how the marker interacts with other markers and labels on the map. See CollisionBehavior for more information.

color?: AttributeValue<PlaceResult, string>

The color of the marker. Can be specified in any format supported by CSS.

This is a shorthand property to set a default value for the three color-values (backgroundColor, borderColor and glyphColor) to matching colors.

The backgroundColor will be set to the specified color, the border-color will be a darkened vertsion of the color and the glyph-color is set based on the brightness of the specified color to either a darkened or lightened version.

content?: AttributeValue<PlaceResult, HTMLElement>

The content to replace the default pin. The specified html-element will be rendered instead of the default pin.

The content element you provide here will have access to the style-properties of the marker (colors and scale) via css custom properties (e.g. color: var(--marker-glyph-color, white)).

draggable?: AttributeValue<PlaceResult, boolean>

Flag to enable draggable markers. When using draggable markers, the position-attribute of the marker will not be automatically updated. You have to listen to the dragstart, drag and dragend events and update the position accordingly.

glyph?: AttributeValue<PlaceResult, string | Element | URL>

The glyph to be shown inside the marker-pin. This can be a single letter or number, a dom-element or a URL-object pointing to an image file.

glyphColor?: AttributeValue<PlaceResult, string>

The color of the glyph within the marker pin. Can be specified in any format supported by CSS.

icon?: AttributeValue<PlaceResult, string>

The id of an icon to be fetched via the icons.IconProvider. The resulting icon will be shown

position?: AttributeValue<PlaceResult, Position>

The position of the marker on the map.

scale?: AttributeValue<PlaceResult, number>

The scale of the marker as a multiple of the original scale.

title?: AttributeValue<PlaceResult, string>

The title of the marker element. Will be shown in the browsers default tooltip and should be provided for accessibility reasons.

zIndex?: AttributeValue<PlaceResult, number>

Defines the z-ordering for the marker and is used to compute the priority for collision handling. See the official documentation for more information.

Accessors

  • get map(): null | Map

    Stores the map-instance. The map will be passed on to the AdvancedMarkerElement in performUpdate().

    Returns null | Map

  • set map(map: null | Map): void

    Parameters

    • map: null | Map

    Returns void

  • get place(): null | PlaceResult

    Returns null | PlaceResult

  • set place(place: null | PlaceResult): void

    Parameters

    • place: null | PlaceResult

    Returns void

Methods

  • Adds an event-listener to this marker. The internal events (click and dragging events) are attached to the marker instance using the Google Maps event system, while any dom-events will be added to the marker-element itself.

    Type Parameters

    • K extends keyof GoogleMapsAMVEventMap

    Parameters

    • eventName: K

      'click', 'dragstart', 'dragend', 'drag' or any DOM event-name.

    • handler: (ev: GoogleMapsAMVEventMap[K]) => void

    Returns MapsEventListener

  • Adds an event-listener to this marker. The internal events (click and dragging events) are attached to the marker instance using the Google Maps event system, while any dom-events will be added to the marker-element itself.

    Type Parameters

    • K extends keyof HTMLElementEventMap

    Parameters

    • eventName: K

      'click', 'dragstart', 'dragend', 'drag' or any DOM event-name.

    • handler: (ev: HTMLElementEventMap[K]) => void

    Returns MapsEventListener

  • Internal

    Retrieve the parameters to be passed to dynamic attribute callbacks. This method is part of the internal API used by the ComputedMarkerAttributes.

    Returns { data: null | PlaceResult; map: MapState; marker: MarkerState }

  • Sets the data for this marker and triggers an update.

    Parameters

    • data: PlaceResult

    Returns void

  • Schedules an update of the marker, writing all attribute values to the underlying advanced marker objects. Calling this manually should not be needed.

    Returns void

  • Registers a new icon provider that resolves the value of the icon-attribute to something that can be used as glyph. When multiple providers are used, you can additionally provide a namespace for the icons.

    For example:

    marker.icon = 'star'; // requests the 'star' icon from the 'default' provider
    marker.icon = 'other:star'; // requests the icon from the 'other' provider
    

    Parameters

    Returns void