Class BaseVectorLayer<S extends AbstractVectorSource>

All Implemented Interfaces:
HasBaseLayerOptions, HasBaseVectorOptions, Serializable
Direct Known Subclasses:
NoOpVectorLayer, VectorLayer

public abstract class BaseVectorLayer<S extends AbstractVectorSource> extends Layer<S> implements HasBaseVectorOptions
Base class for layers with vector data that is rendered client-side.

For more details see: BaseVectorLayer docs

See Also:
  • Field Details

  • Constructor Details

    • BaseVectorLayer

      public BaseVectorLayer()
  • Method Details

    • getRenderBuffer

      public Double getRenderBuffer()
      Specified by:
      getRenderBuffer in interface HasBaseVectorOptions
      Returns:
      the render buffer in pixels, null value means that default value is used: 100
    • setRenderBuffer

      public void setRenderBuffer(Double renderBuffer)
      Description copied from interface: HasBaseVectorOptions
      Sets the buffer in pixels around the viewport extent used by the renderer when getting features from the vector source for the rendering or hit-detection. The hit detection only checks features that are within a certain distance of the given position. For large icons, the actual geometry of a feature might be too far away and is not considered. Recommended value: the size of the largest symbol, line width or label.

      Note, render buffer is set only at creation time and cannot be changed at runtime.

      For more details see: BaseVectorLayer docs

      Specified by:
      setRenderBuffer in interface HasBaseVectorOptions
    • withRenderBuffer

      public BaseVectorLayer<S> withRenderBuffer(Double renderBuffer)
      Parameters:
      renderBuffer -
      Returns:
      current instance
    • isDeclutter

      public Boolean isDeclutter()
      Specified by:
      isDeclutter in interface HasBaseVectorOptions
      Returns:
      whether declutter images and texts, null value means that default value is used: false
    • setDeclutter

      public void setDeclutter(Boolean declutter)
      Description copied from interface: HasBaseVectorOptions
      Sets whether declutter images and texts. Decluttering is applied to all image and text styles of all vector layers that have set this to true. The priority is defined by the z-index of the layer, the Style.withZIndex(Integer) of the style and the render order of features. Higher z-index means higher priority. Within the same z-index, a feature rendered before another has higher priority.

      As an optimization decluttered features from layers with the same HasBaseLayerOptions.setClassName(String) are rendered above the Fill and Stroke styles of all of those layers regardless of z-index. To opt out of this behavior and place declutterd features with their own layer configure the layer with a className other than 'ol-layer'.

      The default value is false.

      Note, declutter is set only at creation time and cannot be changed at runtime.

      For more details see: BaseVectorLayer docs

      Specified by:
      setDeclutter in interface HasBaseVectorOptions
      Parameters:
      declutter - whether declutter images and texts
    • withDeclutter

      public BaseVectorLayer<S> withDeclutter(Boolean declutter)
      Parameters:
      declutter -
      Returns:
      current instance
    • getBackground

      public String getBackground()
      Specified by:
      getBackground in interface HasBaseVectorOptions
      Returns:
      background color for the layer or null if not set
    • setBackground

      public void setBackground(String color)
      Description copied from interface: HasBaseVectorOptions
      Sets the background color for the layer. If not specified, no background will be rendered.

      Note, background color is set only at creation time and cannot be changed at runtime.

      For more details see: BaseVectorLayer docs

      Specified by:
      setBackground in interface HasBaseVectorOptions
      Parameters:
      color - color to set
    • withBackground

      public BaseVectorLayer<S> withBackground(String color)
      Parameters:
      color -
      Returns:
      current instance
    • isUpdateWhileAnimating

      public Boolean isUpdateWhileAnimating()
      Specified by:
      isUpdateWhileAnimating in interface HasBaseVectorOptions
      Returns:
      whether feature batches will be recreated during animations, null value means that default value is used: false
    • setUpdateWhileAnimating

      public void setUpdateWhileAnimating(Boolean updateWhileAnimating)
      Description copied from interface: HasBaseVectorOptions
      Sets whether feature batches will be recreated during animations. This means that no vectors will be shown clipped, but the setting will have a performance impact for large amounts of vector data. When set to false, batches will be recreated when no animation is active.

      The default value is false.

      Note, "updateWhileAnimating" is set only at creation time and cannot be changed at runtime. For more details see: BaseVectorLayer docs

      Specified by:
      setUpdateWhileAnimating in interface HasBaseVectorOptions
      Parameters:
      updateWhileAnimating - whether feature batches will be recreated during animations
    • withUpdateWhileAnimating

      public BaseVectorLayer<S> withUpdateWhileAnimating(Boolean updateWhileAnimating)
      Parameters:
      updateWhileAnimating -
      Returns:
    • getUpdateWhileInteracting

      public Boolean getUpdateWhileInteracting()
      Specified by:
      getUpdateWhileInteracting in interface HasBaseVectorOptions
      Returns:
      whether feature batches will be recreated during interactions, null value means that default value is used: false
    • setUpdateWhileInteracting

      public void setUpdateWhileInteracting(Boolean updateWhileInteracting)
      Description copied from interface: HasBaseVectorOptions
      Sets whether feature batches will be recreated during interactions. The default value is false.

      For instance, if the user moves map by mouse, the features that were not visible will be drawn after the user releases the pressed mouse. To enable always drawing features, set property to true.

      Note, "updateWhileInteracting" is set only at creation time and cannot be changed at runtime.

      For more details see: BaseVectorLayer docs

      Specified by:
      setUpdateWhileInteracting in interface HasBaseVectorOptions
      Parameters:
      updateWhileInteracting - whether feature batches will be recreated during interactions
    • withUpdateWhileInteracting

      public BaseVectorLayer<S> withUpdateWhileInteracting(Boolean updateWhileInteracting)
      Parameters:
      updateWhileInteracting -
      Returns:
      current instance
    • getStyles

      public List<Style> getStyles()
      Returns:
      layer's styles or empty list
    • addStyles

      public BaseVectorLayer<S> addStyles(Style... styles)
      Adds styles that should be merged with default. Layer's styles are applied for all added features, except features with own style.
      Parameters:
      styles - styles to add
      Returns:
      current instance
    • removeStyles

      public void removeStyles(Style... styles)
      Removes provided styles from layer.
      Parameters:
      styles - styles to remove
    • removeAllStyles

      public void removeAllStyles()
      Clears list of styles.
    • getOptions

      protected HasBaseVectorOptions getOptions()
      Specified by:
      getOptions in class Layer<S extends AbstractVectorSource>