All Implemented Interfaces:
Serializable, Evented, Identifiable, LayerPopupFunctions, LayerTooltipFunctions, ExecutableFunctions
Direct Known Subclasses:
TileLayer

public class GridLayer extends Layer
Generic class for handling a tiled grid of HTML elements. This is the base class for all tile layers.
Since:
2020-03-06
Version:
1.0
Author:
Gabor Kokeny Email: kokeny19@gmail.com
See Also:
  • Constructor Details

    • GridLayer

      public GridLayer()
      Creates a new grid layer rendered in the map's tilePane.
  • Method Details

    • onLoading

      public void onLoading(LeafletEventListener<LeafletEvent> listener)
      Fired when the grid layer starts loading tiles.
      Parameters:
      listener - the listener to call when the event occurs, not null
    • onTileUnload

      public void onTileUnload(LeafletEventListener<TileEvent> listener)
      Fired when a tile is removed (e.g. when a tile goes off the screen).
      Parameters:
      listener - the listener to call when the event occurs, not null
    • onTileLoadStart

      public void onTileLoadStart(LeafletEventListener<TileEvent> listener)
      Fired when a tile is requested and starts loading.
      Parameters:
      listener - the listener to call when the event occurs, not null
    • onTileError

      public void onTileError(LeafletEventListener<TileEvent> listener)
      Fired when there is an error loading a tile.
      Parameters:
      listener - the listener to call when the event occurs, not null
    • onTileLoad

      public void onTileLoad(LeafletEventListener<TileEvent> listener)
      Fired when a tile loads.
      Parameters:
      listener - the listener to call when the event occurs, not null
    • onLoad

      public void onLoad(LeafletEventListener<LeafletEvent> listener)
      Fired when the grid layer loaded all visible tiles.
      Parameters:
      listener - the listener to call when the event occurs, not null
    • getTileSize

      public int getTileSize()
      Gets the width and height of tiles in the grid.
      Returns:
      the tileSize
    • setTileSize

      public void setTileSize(int tileSize)
      Width and height of tiles in the grid.
      Parameters:
      tileSize - the tileSize to set
    • getOpacity

      public double getOpacity()
      Gets the opacity of the tiles.
      Returns:
      the opacity
    • setOpacity

      public void setOpacity(double opacity)
      Opacity of the tiles.
      Parameters:
      opacity - the opacity to set
    • isUpdateWhenIdle

      public boolean isUpdateWhenIdle()
      Gets whether new tiles are loaded only when panning ends.
      Returns:
      the updateWhenIdle
    • setUpdateWhenIdle

      public void setUpdateWhenIdle(boolean updateWhenIdle)
      Load new tiles only when panning ends. true by default on mobile browsers, in order to avoid too many requests and keep smooth navigation. false otherwise in order to display new tiles during panning, since it is easy to pan outside the keepBuffer option in desktop browsers.
      Parameters:
      updateWhenIdle - the updateWhenIdle to set
    • isUpdateWhenZooming

      public boolean isUpdateWhenZooming()
      Gets whether the grid layer is updated on every integer zoom level during a smooth zoom animation.
      Returns:
      the updateWhenZooming
    • setUpdateWhenZooming

      public void setUpdateWhenZooming(boolean updateWhenZooming)
      By default, a smooth zoom animation (during a touch zoom or a flyTo()) will update grid layers every integer zoom level. Setting this option to false will update the grid layer only when the smooth animation ends.
      Parameters:
      updateWhenZooming - the updateWhenZooming to set
    • getUpdateInterval

      public int getUpdateInterval()
      Gets the minimum interval, in milliseconds, between tile updates while panning.
      Returns:
      the updateInterval
    • setUpdateInterval

      public void setUpdateInterval(int updateInterval)
      Tiles will not update more than once every updateInterval milliseconds when panning.
      Parameters:
      updateInterval - the updateInterval to set
    • getzIndex

      public int getzIndex()
      Gets the explicit zIndex of the tile layer.
      Returns:
      the zIndex
    • setzIndex

      public void setzIndex(int zIndex)
      The explicit zIndex of the tile layer.
      Parameters:
      zIndex - the zIndex to set
    • getBounds

      public LatLngBounds getBounds()
      Gets the geographical bounds outside of which tiles are not loaded.
      Returns:
      the bounds
    • setBounds

      public void setBounds(LatLngBounds bounds)
      If set, tiles will only be loaded inside the set LatLngBounds.
      Parameters:
      bounds - the bounds to set
    • getMinZoom

      public Integer getMinZoom()
      Gets the minimum zoom level down to which this layer is displayed (inclusive).
      Returns:
      the minZoom
    • setMinZoom

      public void setMinZoom(Integer minZoom)
      The minimum zoom level down to which this layer will be displayed (inclusive).
      Parameters:
      minZoom - the minZoom to set
    • getMaxZoom

      public Integer getMaxZoom()
      Gets the maximum zoom level up to which this layer is displayed (inclusive).
      Returns:
      the maxZoom
    • setMaxZoom

      public void setMaxZoom(Integer maxZoom)
      The maximum zoom level up to which this layer will be displayed (inclusive).
      Parameters:
      maxZoom - the maxZoom to set
    • isNoWrap

      public boolean isNoWrap()
      Gets whether the layer is prevented from wrapping around the antimeridian.
      Returns:
      the noWrap
    • setNoWrap

      public void setNoWrap(boolean noWrap)
      Whether the layer is wrapped around the antimeridian. If true, the GridLayer will only be displayed once at low zoom levels. Has no effect when the map CRS doesn't wrap around. Can be used in combination with bounds to prevent requesting tiles outside the CRS limits.
      Parameters:
      noWrap - the noWrap to set
    • getClassName

      public String getClassName()
      Gets the custom class name assigned to the tile layer.
      Returns:
      the className
    • setClassName

      public void setClassName(String className)
      A custom class name to assign to the tile layer. Empty by default.
      Parameters:
      className - the className to set
    • getKeepBuffer

      public int getKeepBuffer()
      Gets the number of rows and columns of tiles kept before unloading them when panning.
      Returns:
      the keepBuffer
    • setKeepBuffer

      public void setKeepBuffer(int keepBuffer)
      When panning the map, keep this many rows and columns of tiles before unloading them.
      Parameters:
      keepBuffer - the keepBuffer to set