com.vaadin.flow.component.map.configuration.feature.
Class MarkerFeature
- java.lang.Object
-
- com.vaadin.flow.component.map.configuration.AbstractConfigurationObject
-
- com.vaadin.flow.component.map.configuration.Feature
-
- com.vaadin.flow.component.map.configuration.feature.PointBasedFeature
-
- com.vaadin.flow.component.map.configuration.feature.MarkerFeature
-
All Implemented Interfaces:
public class MarkerFeature extends PointBasedFeature
A convenience class for displaying icons or images, such as markers, at a specific location on the map.
Technically this is a
Feature
that uses aPoint
geometry for representation, and a visualStyle
configured to use anIcon
.The class provides a default marker icon if no custom icon is provided.
See Also:
-
-
Field Summary
Fields Modifier and Type Field Description static Icon
PIN_ICON
The default icon used for markers, which is a pin pointing at a location on the map
static Icon
POINT_ICON
An alternative icon that displays a point
-
Fields inherited from class com.vaadin.flow.component.map.configuration.AbstractConfigurationObject
propertyChangeSupport
-
-
Constructor Summary
Constructors Constructor Description MarkerFeature()
Creates a new marker feature displaying a default marker icon.
MarkerFeature(Coordinate coordinates)
Creates a new marker feature located at the specified coordinates, displaying a default marker icon.
MarkerFeature(Coordinate coordinates, Icon icon)
Creates a new marker feature located at the specified coordinates, displaying the specified custom icon.The coordinates must be in the same projection as the
View.getProjection()
andSource.getProjection()
.
-
Method Summary
All Methods Modifier and Type Method Description Icon
getIcon()
The icon used to visually display the marker feature.
void
setIcon(Icon icon)
Sets the icon used to visually display the marker feature.
-
Methods inherited from class com.vaadin.flow.component.map.configuration.feature.PointBasedFeature
getCoordinates, getGeometry, setCoordinates, setGeometry
-
Methods inherited from class com.vaadin.flow.component.map.configuration.Feature
getStyle, getType, setStyle
-
Methods inherited from class com.vaadin.flow.component.map.configuration.AbstractConfigurationObject
addChild, addPropertyChangeListener, collectChanges, deepMarkAsDirty, getId, markAsDirty, notifyChange, notifyChange, removeChild, removePropertyChangeListener, setId, update
-
-
-
-
Constructor Detail
-
MarkerFeature
public MarkerFeature()
Creates a new marker feature displaying a default marker icon.
-
MarkerFeature
public MarkerFeature(Coordinate coordinates)
Creates a new marker feature located at the specified coordinates, displaying a default marker icon. The coordinates must be in the same projection as the
View.getProjection()
andSource.getProjection()
.Parameters:
coordinates
- the coordinates that locate the feature
-
MarkerFeature
public MarkerFeature(Coordinate coordinates, Icon icon)
Creates a new marker feature located at the specified coordinates, displaying the specified custom icon.The coordinates must be in the same projection as the
View.getProjection()
andSource.getProjection()
.NOTE: Icon instances should be reused between features in order to optimize memory-usage in the client-side component / browser. Creating a new instance of an icon for each feature is considered bad practice.
Parameters:
coordinates
- the coordinates that locate the featureicon
- the icon to display the feature
-
-
Method Detail
-
getIcon
public Icon getIcon()
The icon used to visually display the marker feature. By default, this is a default marker icon provided by the component.
CAUTION: Be careful when modifying the returned icon. Icon instances can, and should always be, reused between multiple markers. Modifying an icon can also affect other marker features. Instead of modifying the icon, consider preparing a set of distinct icons, and then using
setIcon(Icon)
.Returns:
the current icon
-
setIcon
public void setIcon(Icon icon)
Sets the icon used to visually display the marker feature.
NOTE: Icon instances should be reused between features in order to optimize memory-usage in the client-side component / browser. Creating a new instance of an icon for each feature is considered bad practice.
Parameters:
icon
- the new icon, not null
-
-