Class BundledTileSource

java.lang.Object
com.codename1.maps.vector.BundledTileSource
All Implemented Interfaces:
TileSource

public final class BundledTileSource extends Object implements TileSource

A TileSource that loads tiles from application resources bundled into the app (the classpath), with no network access. It powers offline maps and, crucially, the deterministic map screenshot tests: a small fixture tileset is shipped as a resource and rendered identically on every run.

The resource path is a template containing the literal tokens {z}, {x} and {y} (for example /maptiles/{z}/{x}/{y}.mvt).

  • Constructor Details

    • BundledTileSource

      public BundledTileSource(String pathTemplate, boolean vector, int minZoom, int maxZoom)

      Creates a bundled source.

      Parameters
      • pathTemplate: a resource path containing {z}/{x}/{y} tokens

      • vector: true for MVT tiles, false for raster image tiles

      • minZoom: the smallest available zoom

      • maxZoom: the largest available zoom

  • Method Details

    • setAttribution

      public BundledTileSource setAttribution(String attribution)
      Sets the attribution string shown over the map.
    • isVector

      public boolean isVector()
      True for MVT vector tiles, false for raster image tiles.
      Specified by:
      isVector in interface TileSource
    • getTileSize

      public int getTileSize()
      The tile edge in pixels (almost always 256).
      Specified by:
      getTileSize in interface TileSource
    • getMinZoom

      public int getMinZoom()
      The smallest zoom level this source serves.
      Specified by:
      getMinZoom in interface TileSource
    • getMaxZoom

      public int getMaxZoom()
      The largest zoom level this source serves.
      Specified by:
      getMaxZoom in interface TileSource
    • getAttribution

      public String getAttribution()
      Attribution text that must be displayed over the map.
      Specified by:
      getAttribution in interface TileSource
    • fetchTile

      public void fetchTile(int z, int x, int y, TileCallback callback)
      Requests the tile at z/x/y, delivering the result to callback on the event dispatch thread.
      Specified by:
      fetchTile in interface TileSource