public class HttpTileSource

  1. Object
  2. HttpTileSource

ImplementsTileSource

Known subtypesMvtTileSource, RasterTileSource

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).

Constructors

public HttpTileSource(String urlTemplate, boolean vector, int minZoom, int maxZoom)Creates an HTTP tile source.

Methods

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

Inherited methods

Constructor details

HttpTileSource

public HttpTileSource(String urlTemplate, boolean vector, int minZoom, int maxZoom)
Creates an HTTP tile source.

Parameters

urlTemplate String
a URL with {z}/{x}/{y} (and optional {key}) tokens
vector boolean
true for MVT tiles, false for raster image tiles
minZoom int
the smallest available zoom
maxZoom int
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.

getTileSize

public int getTileSize()
The tile edge in pixels (almost always 256).

getMinZoom

public int getMinZoom()
The smallest zoom level this source serves.

getMaxZoom

public int getMaxZoom()
The largest zoom level this source serves.

getAttribution

public String getAttribution()
Attribution text that must be displayed over the map.

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.