Class MultiMarkerFeature
- All Implemented Interfaces:
FeatureClickNotifier<MultiMarkerFeature>
,HasFeatureModifyStyles
,HasFeatureSelectStyles
,Serializable
MultiPointGeometry
. It is displayed with marker icon in a map
component.
Usage example:
private void addMultiMarker(VectorSource vectorSource) { MultiPoint multiPoint = factory.createMultiPoint(new Point[]{ createPoint(25.235641166883457, 39.917862345662456), createPoint(25.36806516981515, 37.08014053731078)}); vectorSource.addFeature(new MultiMarkerFeature(multiPoint)); }
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class io.jmix.mapsflowui.kit.component.model.MapObservableObject
MapObservableObject.ObjectChangeEvent
Nested classes/interfaces inherited from interface io.jmix.mapsflowui.component.model.feature.FeatureClickNotifier
FeatureClickNotifier.AbstractFeatureClickEvent<F>, FeatureClickNotifier.FeatureClickEvent<F extends Feature>, FeatureClickNotifier.FeatureDoubleClickEvent<F extends Feature>, FeatureClickNotifier.FeatureSingleClickEvent<F extends Feature>
-
Field Summary
Fields inherited from class io.jmix.mapsflowui.kit.component.model.feature.Feature
geometry, modifyStyles, properties, selectStyles, styles
Fields inherited from class io.jmix.mapsflowui.kit.component.model.MapObservableObject
children, dirty, eventBus, metaProperties, parent, removedChildren, syncId
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.shared.Registration
Adds feature click listener.com.vaadin.flow.shared.Registration
addDoubleClickListener
(Consumer<FeatureClickNotifier.FeatureDoubleClickEvent<MultiMarkerFeature>> listener) Adds feature double click listener.void
addModifyStyles
(Style... styles) Adds modify styles to a feature.void
addSelectStyles
(Style... styles) Adds select styles to a feature.com.vaadin.flow.shared.Registration
addSingleClickListener
(Consumer<FeatureClickNotifier.FeatureSingleClickEvent<MultiMarkerFeature>> listener) Adds feature single click listener.void
Adds style to the feature.org.locationtech.jts.geom.MultiPoint
void
setMultiPoint
(org.locationtech.jts.geom.MultiPoint multiPoint) Sets multipoint to the feature's geometry.withModifyStyles
(Style... styles) withProperties
(Map<String, Object> properties) Sets the properties that will be associated with the feature.withProperty
(String name, Object value) Sets the property that will be associated with the feature.withSelectStyles
(Style... styles) withStyles
(Style... styles) SeeaddStyles(Style...)
.Methods inherited from class io.jmix.mapsflowui.kit.component.model.feature.Feature
addAllModifyStyles, addAllSelectStyles, getModifyStyles, getProperties, getSelectStyles, getStyles, getType, removeAllModifyStyles, removeAllProperties, removeAllSelectStyles, removeAllStyles, removeModifyStyles, removeProperty, removeSelectStyles, removeStyles, updateModifyStyleIds, updateSelectStyleIds
Methods inherited from class io.jmix.mapsflowui.kit.component.model.MapObservableObject
addChild, addListener, clearRemovedChildren, clearRemovedChildrenInDepth, equals, fireChangeEvent, getChildren, getEventBus, getMetaProperties, getRemovedChildren, getSuperParent, getSyncId, hashCode, isAttachedToMap, isDirty, isDirtyInDepth, markAsDirty, markAsDirtyInDepth, removeChild, setMetaProperty, setParent, unmarkDirtyInDepth
-
Constructor Details
-
MultiMarkerFeature
public MultiMarkerFeature(org.locationtech.jts.geom.MultiPoint multiPoint)
-
-
Method Details
-
getGeometry
- Overrides:
getGeometry
in classFeature
- Returns:
- feature's geometry
-
getMultiPoint
public org.locationtech.jts.geom.MultiPoint getMultiPoint()- Returns:
- multipoint from feature's geometry
getGeometry()
-
setMultiPoint
public void setMultiPoint(org.locationtech.jts.geom.MultiPoint multiPoint) Sets multipoint to the feature's geometry.- Parameters:
multiPoint
- multipoint to set
-
addStyles
Adds style to the feature. Note, if the feature contains custom styles, the default styles or added ones to the layer won't be applied to this feature. And you have to provide fully described style to the specific feature.MultiMarkerFeature
by default contains icon style. If you want to replace default icon, at first remove default style usingFeature.removeAllStyles()
and then add new one.If it is needed to apply additional style, just add a new one. For instance:
new MultiMarkerFeature(multiPoint) .withStyles(new MarkerStyle() .withText(new TextStyle() .withText("Departure") .withOffsetY(10)) .build());
-
withStyles
SeeaddStyles(Style...)
.- Overrides:
withStyles
in classFeature
- Parameters:
styles
- styles to add- Returns:
- current instance
-
addSelectStyles
Adds select styles to a feature. The styles will be applied for a feature's geometry when the user selects it.To enable select mode set
SupportsFeatureSelect.setFeatureSelectEnabled(Boolean)
totrue
.The
MultiMarkerFeature
contains default select style. If you want to replace the default icon by new one, remove default style usingFeature.removeAllSelectStyles()
and then add new one. For instance, custom select style for multi-marker feature:MultiMarkerFeature multiMarkerFeature = new MultiMarkerFeature(multiPoint); multiMarkerFeature.removeAllSelectStyles(); // remove default select style multiMarkerFeature.withSelectStyles( new MarkerStyle() .withImage(new IconStyle() .withSrc("icons/icon.png") .withScale(0.05) .withAnchorOrigin(IconOrigin.BOTTOM_LEFT) .withAnchor(new Anchor(0.49, 0.12))) .build());
- Specified by:
addSelectStyles
in interfaceHasFeatureSelectStyles
- Overrides:
addSelectStyles
in classFeature
- Parameters:
styles
- styles to add
-
withSelectStyles
- Overrides:
withSelectStyles
in classFeature
- Parameters:
styles
- styles to add- Returns:
- current instance
-
addModifyStyles
Adds modify styles to a feature.Note, modify styles will be applied not to the feature's geometry, but to the generated vertex point of the feature's geometry. This is because the map generates a point for geometry's vertices to enable modification: adding new vertex, change vertex position. So the provided styles should be valid for the Point Feature.
To enable modify mode set
SupportsFeatureModify.setFeatureModifyEnabled(Boolean)
totrue
.For instance, custom modify style for multi-marker feature:
new MultiMarkerFeature(point) .withModifyStyles( new PointStyle() .withImage(new CircleStyle() .withRadius(6) .withFill(new Fill("#00B945")) .withStroke(new Stroke() .withLineDash(List.of(4d, 6d)) .withWidth(3d) .withColor("#0776A0"))) .build());
- Specified by:
addModifyStyles
in interfaceHasFeatureModifyStyles
- Overrides:
addModifyStyles
in classFeature
- Parameters:
styles
- styles to add
-
withModifyStyles
- Overrides:
withModifyStyles
in classFeature
- Parameters:
styles
- styles to add- Returns:
- current instance
-
withProperties
Description copied from class:Feature
Sets the properties that will be associated with the feature.For instance, if cluster specified weight property it will try to get it from the feature's properties. The same with heatmap when it is specified its weight property.
Another example of using feature's properties is listening click events in source. For instance:
vectorSource.addSourceFeatureClickListener(event -> { Feature feature = event.getFeature(); String description = (String) feature.getProperties().get("description"); notifications.show(description); });
- Overrides:
withProperties
in classFeature
- Parameters:
properties
- properties to set- Returns:
- current instance
-
withProperty
Description copied from class:Feature
Sets the property that will be associated with the feature.For instance, if cluster specified weight property it will try to get it from the feature's properties. The same with heatmap when it is specified its weight property.
Another example of using feature's properties is listening click events in source. For instance:
vectorSource.addSourceFeatureClickListener(event -> { Feature feature = event.getFeature(); String description = (String) feature.getProperties().get("description"); notifications.show(description); });
- Overrides:
withProperty
in classFeature
- Parameters:
name
- property namevalue
- value- Returns:
- current instance
-
addClickListener
public com.vaadin.flow.shared.Registration addClickListener(Consumer<FeatureClickNotifier.FeatureClickEvent<MultiMarkerFeature>> listener) Description copied from interface:FeatureClickNotifier
Adds feature click listener. Note, if the user makes double click on a feature, theFeatureClickNotifier.FeatureClickEvent
will be fired twice.- Specified by:
addClickListener
in interfaceFeatureClickNotifier<MultiMarkerFeature>
- Parameters:
listener
- listener to add- Returns:
- a registration object for removing an event listener
-
addSingleClickListener
public com.vaadin.flow.shared.Registration addSingleClickListener(Consumer<FeatureClickNotifier.FeatureSingleClickEvent<MultiMarkerFeature>> listener) Description copied from interface:FeatureClickNotifier
Adds feature single click listener. Single click means that an event won't be fired if the user makes double click.- Specified by:
addSingleClickListener
in interfaceFeatureClickNotifier<MultiMarkerFeature>
- Parameters:
listener
- listener to add- Returns:
- a registration object for removing an event listener
-
addDoubleClickListener
public com.vaadin.flow.shared.Registration addDoubleClickListener(Consumer<FeatureClickNotifier.FeatureDoubleClickEvent<MultiMarkerFeature>> listener) Description copied from interface:FeatureClickNotifier
Adds feature double click listener.- Specified by:
addDoubleClickListener
in interfaceFeatureClickNotifier<MultiMarkerFeature>
- Parameters:
listener
- listener to add- Returns:
- a registration object for removing an event listener
-