# Class HttpTileSource

java.lang.Object
com.codename1.maps.vector.HttpTileSource

All Implemented Interfaces:
  `TileSource`

Direct Known Subclasses:
  `MvtTileSource, RasterTileSource`

public class HttpTileSource extends Object implements TileSource

A `TileSource` that fetches tiles over HTTPS from a slippy-map URL template. The template contains `{z}`/`{x}`/`{y}` tokens and, optionally, a `{key}` token substituted with the configured API key. Downloads run on the Codename One network thread and deliver results on the EDT, with transparent gunzip for vector payloads.

When the URL has no `{z}` token it is treated as a TileJSON endpoint: on first use the source fetches that document, reads its `tiles` template and then serves tiles from it. This is how the keyless OpenFreeMap basemap (whose tile URLs are versioned) is supported -- see `MvtTileSource.openFreeMap()`.

This is the shared base for `MvtTileSource` (vector) and `RasterTileSource` (raster).

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `HttpTileSource(String urlTemplate, boolean vector, int minZoom, int maxZoom)`
  Creates an HTTP tile source.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `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.
  `String`
  `getAttribution()`
  Attribution text that must be displayed over the map.
  `int`
  `getMaxZoom()`
  The largest zoom level this source serves.
  `int`
  `getMinZoom()`
  The smallest zoom level this source serves.
  `int`
  `getTileSize()`
  The tile edge in pixels (almost always 256).
  `boolean`
  `isVector()`
  True for MVT vector tiles, false for raster image tiles.
  `HttpTileSource`
  `setApiKey(String apiKey)`
  Sets the API key substituted into the `{key}` token of the template.
  `HttpTileSource`
  `setAttribution(String attribution)`
  Sets the attribution string shown over the map.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### HttpTileSource

    public HttpTileSource(String urlTemplate, boolean vector, int minZoom, int maxZoom)

    Creates an HTTP tile source.

    ###### Parameters

    - `urlTemplate`: a URL with `{z}`/`{x}`/`{y}` (and optional `{key}`) tokens

    - `vector`: true for MVT tiles, false for raster image tiles

    - `minZoom`: the smallest available zoom

    - `maxZoom`: the largest available zoom

- ## Method Details

  - ### setApiKey

    public HttpTileSource setApiKey(String apiKey)
    Sets the API key substituted into the `{key}` token of the template.

  - ### setAttribution

    public HttpTileSource 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`