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:
Serializable
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:
- Serialized Form
-
-
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 mapstatic 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.
-
Method Summary
All Methods Instance Methods Concrete 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. Coordinates must be specified in the map's user projection, which by default isEPSG:4326
, also referred to as GPS coordinates. If the user projection has been changed usingMap.setUserProjection(String)
, then coordinates must be specified in that projection instead.- 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. Coordinates must be specified in the map's user projection, which by default isEPSG:4326
, also referred to as GPS coordinates. If the user projection has been changed usingMap.setUserProjection(String)
, then coordinates must be specified in that projection instead.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
-
-