Class VectorLayer<T>

java.lang.Object
io.jmix.mapsui.component.layer.VectorLayer<T>
All Implemented Interfaces:
Layer, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware

public class VectorLayer<T> extends Object
A layer containing geo-objects (entities having a property of a Geometry type.

This layer acts as a connector between the data (geo-objects provided by VectorLayerItems interface implementation) and the map UI component. It carries the data along with some additional information on how the geo-objects should be displayed on a map (styles, content of popup info windows).

  • Field Details

    • applicationContext

      protected org.springframework.context.ApplicationContext applicationContext
  • Constructor Details

    • VectorLayer

      public VectorLayer(String id)
    • VectorLayer

      public VectorLayer(String id, VectorLayerItems<T> items)
      Creates an instance of VectorLayer.
      Parameters:
      id - layer id
      items - geo-objects provider
    • VectorLayer

      public VectorLayer(String id, InstanceContainer<T> dataContainer)
      Creates an instance of VectorLayer.
      Parameters:
      id - layer id
      dataContainer - dataContainer containing geo-objects
  • Method Details

    • getGeoObjects

      public Collection<? extends T> getGeoObjects()
      Returns an unmodifiable collection of the geo-objects belonging to the layer.
      Returns:
      collection of entities
    • getStyleProvider

      public Function<? super T,GeometryStyle> getStyleProvider()
      Returns the geo-objects style provider.
    • setStyleProvider

      public void setStyleProvider(Function<? super T,GeometryStyle> styleProvider)
      Sets the style provider for a layer's geo-objects, i.e. function that determines style for a corresponding entity's geometry that is displayed on a map.

      Make sure to provide a style of an appropriate type. For example, for geometries of a Point type, style object should be of a PointStyle type. Otherwise, style option will not be applied.

      Parameters:
      styleProvider - function that takes an entity as an argument and produces a GeometryStyle for the entity's geometry
    • getPopupContentProvider

      public Function<? super T,String> getPopupContentProvider()
      Returns the popup content provider.
    • setPopupContentProvider

      public void setPopupContentProvider(Function<? super T,String> popupContentProvider)
      Sets the popup content provider, i.e. function that determines content for bound popups (which will be opened on clicking on the layer's geometries).

      By default, popups are not displayed.

      Parameters:
      popupContentProvider - function that takes an entity as an argument and produces string of content to be displayed inside a popup window
    • getPopupWindowOptions

      public PopupWindowOptions getPopupWindowOptions()
      Returns style parameters for bound popups.
    • setPopupWindowOptions

      public void setPopupWindowOptions(PopupWindowOptions popupWindowOptions)
      Sets the explicit style parameters for bound popups.
    • getTooltipContentProvider

      public Function<? super T,String> getTooltipContentProvider()
    • setTooltipContentProvider

      public void setTooltipContentProvider(Function<? super T,String> tooltipContentProvider)
      Sets the tooltip content provider, i.e. function that determines content for bound tooltips (which will be opened on hovering on the layer's geometries).

      By default, tooltips are not displayed.

      Parameters:
      tooltipContentProvider - function that takes an entity as an argument and produces string of content to be displayed inside a tooltip box
    • getTooltipOptions

      public TooltipOptions getTooltipOptions()
    • setTooltipOptions

      public void setTooltipOptions(TooltipOptions tooltipOptions)
      Sets the explicit style parameters for bound tooltips.
    • getSelectedGeoObject

      public T getSelectedGeoObject()
      Returns the selected geo-object of the layer.
    • setSelectedGeoObject

      public void setSelectedGeoObject(T selectedGeoObject)
      Sets the selected geo-object of the layer.
    • getGeoObjectsProvider

      public VectorLayerItems<T> getGeoObjectsProvider()
      Returns the geo-objects provider
    • setItems

      public void setItems(VectorLayerItems<T> items)
    • setDataContainer

      public void setDataContainer(InstanceContainer<T> dataContainer)
    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
      Throws:
      org.springframework.beans.BeansException
    • addGeoObjectSelectedListener

      public Subscription addGeoObjectSelectedListener(Consumer<VectorLayer.GeoObjectSelectedEvent<T>> listener)
      Registers a new geo-object selected listener.
      Parameters:
      listener - the listener to be added
      Returns:
      a registration object for removing an event listener added to a source
    • addGeoObjectClickListener

      public Subscription addGeoObjectClickListener(Consumer<VectorLayer.GeoObjectClickEvent<T>> listener)
    • getClusteringOptions

      public ClusteringOptions getClusteringOptions()
    • setClusteringOptions

      public void setClusteringOptions(ClusteringOptions clusteringOptions)
    • isSelectGeoObjectOnClick

      public boolean isSelectGeoObjectOnClick()
    • setSelectGeoObjectOnClick

      @StudioProperty(defaultValue="true") public void setSelectGeoObjectOnClick(boolean selectGeoObjectOnClick)
    • getEventHub

      protected EventHub getEventHub()
    • setMaxZoom

      public void setMaxZoom(int maxZoom)
      Description copied from interface: Layer
      Sets maximum zoom level up to which the layer is visible (inclusive).
      Specified by:
      setMaxZoom in interface Layer
      Parameters:
      maxZoom - maximum layer zoom level
    • getMaxZoom

      public int getMaxZoom()
      Description copied from interface: Layer
      Returns maximum layer zoom level.
      Specified by:
      getMaxZoom in interface Layer
      Returns:
      maximum layer zoom level
    • setMinZoom

      public void setMinZoom(int minZoom)
      Description copied from interface: Layer
      Sets minimum zoom level down to which the layer is visible (inclusive).

      Default value: 0.

      Specified by:
      setMinZoom in interface Layer
      Parameters:
      minZoom - minimum layer zoom level
    • getMinZoom

      public int getMinZoom()
      Description copied from interface: Layer
      Returns minimum layer zoom level.
      Specified by:
      getMinZoom in interface Layer
      Returns:
      minimum layer zoom level
    • getId

      public String getId()
      Specified by:
      getId in interface Layer
      Returns:
      ID of a layer
    • setVisible

      public void setVisible(boolean visible)
      Description copied from interface: Layer
      Sets whether the layer should be visible on a map.

      Default value: true.

      Specified by:
      setVisible in interface Layer
      Parameters:
      visible - true/false
    • isVisible

      public boolean isVisible()
      Description copied from interface: Layer
      Whether the layer is to be visible on a map.
      Specified by:
      isVisible in interface Layer
      Returns:
      true if the layer is set to be visible; otherwise false
    • setEditable

      public void setEditable(boolean editable)
      Description copied from interface: Layer
      Sets whether the layer is to be editable on a map.

      Default value: false.

      Specified by:
      setEditable in interface Layer
      Parameters:
      editable - true/false
    • isEditable

      public boolean isEditable()
      Description copied from interface: Layer
      Whether the layer is to be editable on a map.
      Specified by:
      isEditable in interface Layer
      Returns:
      true if the layer is set to be editable; otherwise false
    • fireLayerChangedEvent

      protected void fireLayerChangedEvent(LayerChangedEvent event)
    • refresh

      public void refresh()
      Description copied from interface: Layer
      Notify clients that the layer has changed and need to be redrawn.
      Specified by:
      refresh in interface Layer
    • toString

      public String toString()
      Overrides:
      toString in class Object