Class LeafletMap

java.lang.Object
com.vaadin.flow.component.Component
org.vaadin.addons.componentfactory.leaflet.LeafletMap
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasTheme, Serializable, Evented, SupportsKeyboardEvents, SupportsLayerEvents, SupportsLocationEvents, SupportsMapEvents, SupportsMouseEvents, Identifiable, ExecutableFunctions, GeolocationFunctions, MapConversionFunctions, MapGetStateFunctions, MapModifyStateFunctions

@Tag("leaflet-map") @NpmPackage(value="leaflet", version="1.9.4") @JsModule("./leaflet-map.js") @JsModule("leaflet/dist/leaflet-src.js") @CssImport(value="leaflet/dist/leaflet.css",themeFor="leaflet-map") @CssImport(value="./styles/leaflet-lumo-theme.css",themeFor="leaflet-map") public final class LeafletMap extends com.vaadin.flow.component.Component implements MapModifyStateFunctions, MapGetStateFunctions, GeolocationFunctions, MapConversionFunctions, SupportsMouseEvents, SupportsMapEvents, SupportsLocationEvents, SupportsKeyboardEvents, SupportsLayerEvents, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasTheme, com.vaadin.flow.component.HasStyle
See Also:
  • Constructor Details

    • LeafletMap

      public LeafletMap()
    • LeafletMap

      public LeafletMap(MapOptions mapOptions)
  • Method Details

    • onAttach

      protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
      Overrides:
      onAttach in class com.vaadin.flow.component.Component
    • getLayer

      public Layer getLayer(String layerId)
      Returns the layer with the given internal ID.
      Parameters:
      layerId - the id of the layer to be looking for
      Returns:
      the layer with the given internal ID
    • findLayer

      public Layer findLayer(String layerId)
    • addLayer

      public void addLayer(Layer layer)
      Adds the given layer to the map
      Parameters:
      layer - the layer to add
    • removeLayer

      public void removeLayer(Layer layer)
      Removes the given layer from the map.
      Parameters:
      layer - the layer to remove
    • setBaseUrl

      public void setBaseUrl(String baseUrl)
    • addControl

      public void addControl(LeafletControl leafletControl)
      Adds the given control to the map
      Parameters:
      leafletControl - the control to add
    • removeControl

      public void removeControl(LeafletControl leafletControl)
      Removes the given control from the map
      Parameters:
      leafletControl - the control to remove
    • whenReady

      public com.vaadin.flow.shared.Registration whenReady(com.vaadin.flow.component.ComponentEventListener<LeafletMap.MapReadyEvent> listener)
      Fired when the map gets initialized with a view (center and zoom) and at least one layer, or immediately if it's already initialized.
      Parameters:
      listener - the listener to call when the event occurs, not null
      Returns:
      a handle that can be used for removing the listener
    • addThemeVariants

      public void addThemeVariants(LeafletMapVariant... variants)
      Adds theme variants to the map component.
      Parameters:
      variants - theme variants to add
    • executeJs

      public void executeJs(Identifiable target, String functionName, Serializable... arguments)
      Specified by:
      executeJs in interface ExecutableFunctions
    • call

      public <T extends Serializable> CompletableFuture<T> call(Identifiable target, String functionName, Class<T> resultType, Serializable... arguments)
      Specified by:
      call in interface ExecutableFunctions
    • addEventListener

      public <T extends LeafletEvent> void addEventListener(LeafletEventType eventType, LeafletEventListener<T> listener)
      Description copied from interface: Evented
      Adds a listener function (fn) to a particular event type of the object.
      Specified by:
      addEventListener in interface Evented
      Type Parameters:
      T - the generic type of the leaflet object
      Parameters:
      eventType - type of the event to be listening
      listener - the event listener
    • getUuid

      public String getUuid()
      Specified by:
      getUuid in interface Identifiable
    • removeEventListener

      public void removeEventListener(LeafletEventType eventType)
      Description copied from interface: Evented
      Alias to off(?)
      Specified by:
      removeEventListener in interface Evented
      Parameters:
      eventType - the event type
    • clearAllEventListeners

      public void clearAllEventListeners()
      Description copied from interface: Evented
      Alias to off()
      Specified by:
      clearAllEventListeners in interface Evented
    • hasEventListeners

      public boolean hasEventListeners(LeafletEventType eventType)
      Description copied from interface: Evented
      Alias to listens(?)
      Specified by:
      hasEventListeners in interface Evented
      Parameters:
      eventType - the event type
      Returns:
      true if a particular event type has any listeners attached to it
    • isReady

      public boolean isReady()
      Returns:
      the ready