Class MarkerOptions

java.lang.Object
com.codename1.maps.MarkerOptions

public final class MarkerOptions extends Object

A fluent builder describing a Marker before it is added to a MapSurface. Only the position is required; every other property has a sensible default.

map.addMarker(new MarkerOptions(new LatLng(37.78, -122.40))
        .icon(pin)
        .title("Union Square")
        .anchor(0.5f, 1.0f)
        .onClick(e -> showDetails()));
  • Constructor Details

    • MarkerOptions

      public MarkerOptions(LatLng position)
      Starts a builder for a marker at position.
    • MarkerOptions

      public MarkerOptions()
      Starts a builder with the location supplied later via position.
  • Method Details

    • position

      public MarkerOptions position(LatLng position)
      Sets the marker location.
    • icon

      public MarkerOptions icon(EncodedImage icon)
      Sets the marker icon. When null the surface renders its default pin.
    • title

      public MarkerOptions title(String title)
      Sets the info-window title.
    • snippet

      public MarkerOptions snippet(String snippet)
      Sets the info-window secondary text.
    • anchor

      public MarkerOptions anchor(float u, float v)
      Sets the icon anchor in normalized [0,1] image space.
    • draggable

      public MarkerOptions draggable(boolean draggable)
      Makes the marker draggable (native providers only).
    • onClick

      public MarkerOptions onClick(ActionListener onClick)
      Sets the tap listener.
    • build

      public Marker build()
      Builds an immutable-by-convention Marker from this builder.