com.vaadin.flow.component.map.configuration.

All Implemented Interfaces:

Serializable

Direct Known Subclasses:

PointBasedFeature

public abstract class Feature extends AbstractConfigurationObject

A geographic feature to be displayed on a map. A feature represents a point of interest, such as an address, a building, a vehicle, or any other entity.

See Also:

  • Constructor Details

    • Feature

      public Feature()
  • Method Details

    • getType

      public String getType()

      Description copied from class: AbstractConfigurationObject

      The unique type name of this class. Used by the client-side synchronization mechanism to determine which OpenLayers class to synchronize into.

      Specified by:

      getType in class AbstractConfigurationObject

    • getGeometry

      public SimpleGeometry getGeometry()

      The geometry representing the feature, for example a Point or a polygon.

      Returns:

      the current geometry

    • setGeometry

      public void setGeometry(SimpleGeometry geometry)

      Sets the geometry representing the feature.

      Parameters:

      geometry - the new geometry, not null

    • getStyle

      public Style getStyle()

      The Style defines how the feature should be visually displayed.

      Returns:

      the current style

    • setStyle

      public void setStyle(Style style)

      Sets the style that defines how the feature should be visually displayed.

      Parameters:

      style - the new style, not null

    • getText

      public String getText()

      The text that should be displayed next to the feature.

      Returns:

      the text string

    • setText

      public void setText(String text)

      Sets the text that should be displayed next to the feature. Set to null to remove the text.

      Parameters:

      text - the new text string, or null to remove the text

    • getTextStyle

      public TextStyle getTextStyle()

      Returns the custom text style for rendering this feature's getText(). Returns null by default, which means the text is rendered with a default text style.

      Returns:

      the custom text style, or null if no custom text style has been set

    • setTextStyle

      public void setTextStyle(TextStyle textStyle)

      Sets a custom text style for rendering this feature's getText(). By default, a feature has no custom text style, which means the text is rendered with a default text style. Can be set to null to remove the custom text style.

      This is a convenience method for Style.setTextStyle(TextStyle). If this feature does not have a style instance yet, an empty one is created.

      Parameters:

      textStyle - the new custom text style, or null to remove the custom text style

    • isDraggable

      public boolean isDraggable()

      Whether the feature can be dragged on the map using pointing devices or not

    • setDraggable

      public void setDraggable(boolean draggable)

      Sets whether the feature can be dragged on the map using pointing devices or not. Enabling this will make the feature draggable on the map, indicated by a pointer cursor when hovering over the feature. The feature's position / geometry is automatically updated after dropping the feature. Use MapBase.addFeatureDropListener(ComponentEventListener) to get notified when a feature has been moved.

      Parameters:

      draggable - whether the feature can be dragged or not