public final class

PlaceMarker.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.car.app.model.PlaceMarker.Builder

Overview

A builder of PlaceMarker.

Summary

Constructors
publicBuilder()

Returns an empty PlaceMarker.Builder instance.

Methods
public PlaceMarkerbuild()

Constructs the PlaceMarker defined by this builder.

public PlaceMarker.BuildersetColor(CarColor color)

Sets the color that should be used for the marker on the map.

public PlaceMarker.BuildersetIcon(CarIcon icon, int iconType)

Sets the icon to display in the marker.

public PlaceMarker.BuildersetLabel(java.lang.CharSequence label)

Sets the text that should be displayed as the marker's content.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder()

Returns an empty PlaceMarker.Builder instance.

Methods

public PlaceMarker.Builder setIcon(CarIcon icon, int iconType)

Sets the icon to display in the marker.

Unless set with this method, the marker will not have an icon.

If a label is specified with PlaceMarker.Builder.setLabel(CharSequence), the icon will take precedence over it.

Icon Sizing Guidance

If the input icon's size exceeds the sizing requirements for the given icon type in either one of the dimensions, it will be scaled down to be centered inside the bounding box while preserving its aspect ratio.

See CarIcon for more details related to providing icon and image resources that work with different car screen pixel densities.

Parameters:

icon: the CarIcon to display inside the marker
iconType: one of PlaceMarker.TYPE_ICON or PlaceMarker.TYPE_IMAGE

public PlaceMarker.Builder setLabel(java.lang.CharSequence label)

Sets the text that should be displayed as the marker's content.

Unless set with this method, the marker will not have a label.

If an icon is specified with PlaceMarker.Builder.setIcon(CarIcon, int), the icon will take precedence.

Spans are not supported in the input string and will be ignored.

Parameters:

label: the text to display inside of the marker. The string must have a maximum size of 3 characters. Set to null to let the host choose a labelling scheme (for example, using a sequence of numbers)

See also: CarText

public PlaceMarker.Builder setColor(CarColor color)

Sets the color that should be used for the marker on the map.

This color is applied in the following cases:

  • When the PlaceMarker is displayed on the map, the pin enclosing the icon or label will be painted using the given color.
  • When the PlaceMarker is displayed on the list, the color will be applied if the content is a label. A label rendered inside a map's pin cannot be colored and will always use the default color as chosen by the host.

Unless set with this method, the host will use a default color for the marker.

The host may ignore this color and use the default instead if the color does not pass the contrast requirements.

A color cannot be set if the marker's icon type is of PlaceMarker.TYPE_IMAGE.

public PlaceMarker build()

Constructs the PlaceMarker defined by this builder.