com.vaadin.flow.component.map.configuration.feature.
Class MarkerFeature
All Implemented Interfaces:
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 a Point
geometry for
representation, and a visual Style
configured to use an Icon
.
The class provides a default marker icon if no custom icon is provided.
See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Icon
The default icon used for markers, which is a pin pointing at a location on the map.
static final Icon
An alternative icon that displays a point.
Fields inherited from class com.vaadin.flow.component.map.configuration.AbstractConfigurationObject
propertyChangeSupport
-
Constructor Summary
ConstructorsConstructorDescriptionCreates 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
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, getText, getTextStyle, getType, isDraggable, setDraggable, setStyle, setText, setTextStyle
Methods inherited from class com.vaadin.flow.component.map.configuration.AbstractConfigurationObject
addChild, addNullableChild, addPropertyChangeListener, collectChanges, deepMarkAsDirty, getId, markAsDirty, notifyChange, notifyChange, removeChild, removePropertyChangeListener, setId, update
-
Field Details
-
PIN_ICON
The default icon used for markers, which is a pin pointing at a location on the map. This is a static icon and does not support customization.
-
POINT_ICON
An alternative icon that displays a point. This is a static icon and does not support customization.
-
-
Constructor Details
-
MarkerFeature
public MarkerFeature()Creates a new marker feature displaying a default marker icon.
-
MarkerFeature
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 is
EPSG: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
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 is
EPSG: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 Details
-
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
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
-