java.lang.Object
org.vaadin.addons.componentfactory.leaflet.LeafletObject
org.vaadin.addons.componentfactory.leaflet.layer.Layer
All Implemented Interfaces:
Serializable, Evented, Identifiable, LayerPopupFunctions, LayerTooltipFunctions, ExecutableFunctions
Direct Known Subclasses:
DivOverlay, EsriLeafletLayer, GridLayer, HeatLayer, InteractiveLayer, KmzLayer, LayerGroup

public abstract class Layer extends LeafletObject implements Evented, LayerPopupFunctions, LayerTooltipFunctions
A set of methods from the Layer base class that all Leaflet layers use. Inherits all methods, options and events from L.Evented.
Since:
2020-02-06
Version:
1.0
Author:
Gabor Kokeny Email: kokeny19@gmail.com
See Also:
  • Field Details

    • DEFAULT_PANE

      public static final String DEFAULT_PANE
      The name of the default map pane (overlayPane) used to render a layer.
      See Also:
  • Constructor Details

    • Layer

      protected Layer()
      Creates a new layer rendered in the default DEFAULT_PANE map pane.
  • Method Details

    • unbindTooltip

      public void unbindTooltip()
      Unbinds the tooltip previously bound to this layer and removes it.
      Specified by:
      unbindTooltip in interface LayerTooltipFunctions
    • unbindPopup

      public void unbindPopup()
      Unbinds the popup previously bound to this layer and removes it.
      Specified by:
      unbindPopup in interface LayerPopupFunctions
    • onAdd

      public void onAdd(LeafletEventListener<LeafletEvent> listener)
      Fired after the layer is added to a map
      Parameters:
      listener - the event listener
    • onRemove

      public void onRemove(LeafletEventListener<LeafletEvent> listener)
      Fired after the layer is removed from a map
      Parameters:
      listener - the event listener
    • onTooltipOpen

      public void onTooltipOpen(LeafletEventListener<TooltipEvent> listener)
      Fired when a tooltip bound to this layer is opened.
      Parameters:
      listener - the event listener
    • onTooltipClose

      public void onTooltipClose(LeafletEventListener<TooltipEvent> listener)
      Fired when a tooltip bound to this layer is closed.
      Parameters:
      listener - the event listener
    • onPopupOpen

      public void onPopupOpen(LeafletEventListener<PopupEvent> listener)
      Fired when a popup bound to this layer is opened
      Parameters:
      listener - the event listener
    • onPopupClose

      public void onPopupClose(LeafletEventListener<PopupEvent> listener)
      Fired when a popup bound to this layer is closed
      Parameters:
      listener - the event listener
    • fireEvent

      public <T extends LeafletEvent> void fireEvent(T leafletEvent)
      Dispatches the given event to all listeners registered for its event type.
      Type Parameters:
      T - the type of the Leaflet event
      Parameters:
      leafletEvent - the event to fire
    • addTo

      public void addTo(LayerGroup layerGroup)
      Adds the layer to the given layer group
      Parameters:
      layerGroup - the layer group
    • addTo

      public void addTo(LeafletMap leafletMap)
      Adds the layer to the given map
      Parameters:
      leafletMap - the leaflet map
    • getEvents

      public List<String> getEvents()
      Returns the Leaflet event names this layer currently listens to.
      Returns:
      the list of registered event names
    • getAttribution

      public String getAttribution()
      Returns the attribution string shown for this layer.
      Returns:
      the attribution text, or null if none is set
    • setAttribution

      public void setAttribution(String attribution)
      Sets the attribution string shown for this layer.
      Parameters:
      attribution - the attribution text to set
    • getPane

      public String getPane()
      Returns the name of the map pane in which this layer is rendered.
      Returns:
      the pane name
    • setPane

      public void setPane(String pane)
      Sets the name of the map pane in which this layer is rendered.
      Parameters:
      pane - the pane name to set
    • getPopup

      public Popup getPopup()
      Returns the popup bound to this layer.
      Specified by:
      getPopup in interface LayerPopupFunctions
      Returns:
      the bound popup, or null if none is bound
    • bindPopup

      public void bindPopup(String popupContent)
      Binds a popup with the given HTML content to this layer.
      Specified by:
      bindPopup in interface LayerPopupFunctions
      Parameters:
      popupContent - the HTML content of the popup
    • bindPopup

      public void bindPopup(Popup popup)
      Binds the given popup to this layer.
      Specified by:
      bindPopup in interface LayerPopupFunctions
      Parameters:
      popup - the popup to bind
    • getTooltip

      public Tooltip getTooltip()
      Returns the tooltip bound to this layer.
      Specified by:
      getTooltip in interface LayerTooltipFunctions
      Returns:
      the bound tooltip, or null if none is bound
    • bindTooltip

      public void bindTooltip(String tooltipContent)
      Binds a tooltip with the given content to this layer.
      Specified by:
      bindTooltip in interface LayerTooltipFunctions
      Parameters:
      tooltipContent - the content of the tooltip
    • bindTooltip

      public void bindTooltip(Tooltip tooltip)
      Binds the given tooltip to this layer.
      Specified by:
      bindTooltip in interface LayerTooltipFunctions
      Parameters:
      tooltip - the tooltip to bind
    • set

      public <T> void set(Supplier<CompletableFuture<T>> futureResult, Consumer<T> handler)
      Resolves the given asynchronous result and passes it to the handler once it becomes available.
      Type Parameters:
      T - the type of the asynchronous result
      Parameters:
      futureResult - a supplier of the future result
      handler - the consumer invoked with the resolved result
    • addEventListener

      public <T extends LeafletEvent> void addEventListener(LeafletEventType eventType, LeafletEventListener<T> listener)
      Registers a listener for the given event type on this layer.
      Specified by:
      addEventListener in interface Evented
      Type Parameters:
      T - the type of the Leaflet event
      Parameters:
      eventType - the event type to listen for
      listener - the listener to invoke when the event occurs
    • clearAllEventListeners

      public void clearAllEventListeners()
      Removes all event listeners registered on this layer.
      Specified by:
      clearAllEventListeners in interface Evented
    • hasEventListeners

      public boolean hasEventListeners(LeafletEventType eventType)
      Returns whether at least one listener is registered for the given event type.
      Specified by:
      hasEventListeners in interface Evented
      Parameters:
      eventType - the event type to check
      Returns:
      true if a listener is registered for the event type
    • removeEventListener

      public void removeEventListener(LeafletEventType eventType)
      Removes all listeners registered for the given event type.
      Specified by:
      removeEventListener in interface Evented
      Parameters:
      eventType - the event type whose listeners should be removed
    • remove

      public void remove()
      Removes the layer from the map it is currently active on