Class MultiMarkerFeature

All Implemented Interfaces:
FeatureClickNotifier<MultiMarkerFeature>, Serializable

public class MultiMarkerFeature extends Feature implements FeatureClickNotifier<MultiMarkerFeature>
Multi marker feature with predefined 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:
  • Constructor Details

    • MultiMarkerFeature

      public MultiMarkerFeature(org.locationtech.jts.geom.MultiPoint multiPoint)
  • Method Details

    • getGeometry

      public MultiPointGeometry getGeometry()
      Overrides:
      getGeometry in class Feature
      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

      public void addStyles(Style... styles)
      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.

      MarkerFeature by default contains icon style. If you want to change icon, at first remove default style using Feature.removeAllStyles() and then add new one.

      If it is need 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());
       
      Overrides:
      addStyles in class Feature
      Parameters:
      styles - styles to add
    • withStyles

      public MultiMarkerFeature withStyles(Style... styles)
      Overrides:
      withStyles in class Feature
      Parameters:
      styles - styles to add
      Returns:
      current instance
    • withProperties

      public MultiMarkerFeature withProperties(Map<String,Object> properties)
      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 class Feature
      Parameters:
      properties - properties to set
      Returns:
      current instance
    • withProperty

      public MultiMarkerFeature withProperty(String name, Object value)
      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 class Feature
      Parameters:
      name - property name
      value - 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, the FeatureClickNotifier.FeatureClickEvent will be fired twice.
      Specified by:
      addClickListener in interface FeatureClickNotifier<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 interface FeatureClickNotifier<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 interface FeatureClickNotifier<MultiMarkerFeature>
      Parameters:
      listener - listener to add
      Returns:
      a registration object for removing an event listener