Class MapBase

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.map.MapBase
All Implemented Interfaces:
AttachNotifier, DetachNotifier, HasElement, HasSize, HasStyle, HasTheme, HasThemeVariant<MapVariant>, Serializable
Direct Known Subclasses:
Map

public abstract class MapBase extends Component implements HasSize, HasStyle, HasThemeVariant<MapVariant>
Base class for the map component. Contains all base functionality for the map component, but does not provide any defaults. This component should not be used directly, instead use Map, which also provides some out-of-the-box conveniences such as a pre-configured background layer, and a feature layer.
See Also:
  • Constructor Details

    • MapBase

      protected MapBase()
  • Method Details

    • getConfiguration

      protected Configuration getConfiguration()
    • getView

      public View getView()
      Gets the View of the map. The view allows controlling properties of the map's viewport, such as center, zoom level and rotation.
      Returns:
      the map's view
    • setView

      public void setView(View view)
      Sets the view of the map. This is only necessary when dealing with map services that use custom coordinate projection, in which case a view with a matching projection needs to be created and used.
      Parameters:
      view - the new view
    • onAttach

      protected void onAttach(AttachEvent attachEvent)
      Description copied from class: Component
      Called when the component is attached to a UI.

      This method is invoked before the AttachEvent is fired for the component.

      Make sure to call super.onAttach when overriding this method.
      Overrides:
      onAttach in class Component
      Parameters:
      attachEvent - the attach event
    • addViewMoveEndEventListener

      @Deprecated(since="25.0", forRemoval=true) public Registration addViewMoveEndEventListener(ComponentEventListener<MapViewMoveEndEvent> listener)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Adds an event listener for changes to the map's viewport. The event will only be triggered after the user has finished manipulating the viewport, for example after letting go of the mouse button after a mouse drag interaction.
      Parameters:
      listener - the listener to add
      Returns:
      a registration object for removing the added listener
    • addViewMoveEndListener

      public Registration addViewMoveEndListener(ComponentEventListener<MapViewMoveEndEvent> listener)
      Adds an event listener for changes to the map's viewport. The event will only be triggered after the user has finished manipulating the viewport, for example after letting go of the mouse button after a mouse drag interaction.
      Parameters:
      listener - the listener to add
      Returns:
      a registration object for removing the added listener
    • addClickEventListener

      @Deprecated(since="25.0", forRemoval=true) public Registration addClickEventListener(ComponentEventListener<MapClickEvent> listener)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Adds a click listener for the map.

      Note that the listener will also be invoked when clicking on a Feature. Use MapClickEvent.getFeatures() to distinguish whether a feature exists at the clicked location.

      Parameters:
      listener - the listener to add
      Returns:
      a registration object for removing the added listener
    • addClickListener

      public Registration addClickListener(ComponentEventListener<MapClickEvent> listener)
      Adds a click listener for the map.

      Note that the listener will also be invoked when clicking on a Feature. Use MapClickEvent.getFeatures() to distinguish whether a feature exists at the clicked location.

      Parameters:
      listener - the listener to add
      Returns:
      a registration object for removing the added listener
    • addFeatureClickListener

      public Registration addFeatureClickListener(VectorLayer layer, ComponentEventListener<MapFeatureClickEvent> listener)
      Adds a click listener for geographical features. The listener will be invoked for a click on any feature in the specified layer. For clicks on overlapping features, the listener will be invoked only for the top-level feature at that location.

      When clustering is enabled, the listener will only be invoked for clicks on individual features. Use addClusterClickListener(ComponentEventListener) to listen for clicks on clusters.

      Parameters:
      listener - the listener to trigger
      Returns:
      registration for the listener
      See Also:
    • addFeatureClickListener

      public Registration addFeatureClickListener(ComponentEventListener<MapFeatureClickEvent> listener)
      Adds a click listener for geographical features. The listener will be invoked for a click on any feature, in any layer. To listen for feature clicks in a specific layer, see addFeatureClickListener(VectorLayer, ComponentEventListener). For clicks on overlapping features, the listener will be invoked only for the top-level feature at that location.

      When clustering is enabled, the listener will only be invoked for clicks on individual features. Use addClusterClickListener(ComponentEventListener) to listen for clicks on clusters.

      Parameters:
      listener - the listener to trigger
      Returns:
      registration for the listener
      See Also:
    • addClusterClickListener

      public Registration addClusterClickListener(ComponentEventListener<MapClusterClickEvent> listener)
      Adds a click listener for clusters of features. The listener will be invoked for a click on any cluster, in any feature layer. Use addFeatureClickListener(ComponentEventListener) to listen for clicks on individual features.
      Parameters:
      listener - the listener to trigger
      Returns:
      registration for the listener
    • addFeatureDropListener

      public Registration addFeatureDropListener(ComponentEventListener<MapFeatureDropEvent> listener)
      Adds an event listener for when a feature is dropped after a drag operation. Features can be made draggable by setting Feature.setDraggable(boolean).
      Parameters:
      listener - the listener to trigger
      Returns:
      registration for the listener
      See Also: