public class HttpTileSource
- Object
- 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)Parameters
urlTemplateString- a URL with
{z}/{x}/{y}(and optional{key}) tokens vectorboolean- true for MVT tiles, false for raster image tiles
minZoomint- the smallest available zoom
maxZoomint- the largest available zoom
Method details
setApiKey
public HttpTileSource setApiKey(String apiKey){key} token of the template.setAttribution
public HttpTileSource setAttribution(String attribution)isVector
public boolean isVector()getTileSize
public int getTileSize()getMinZoom
public int getMinZoom()getMaxZoom
public int getMaxZoom()getAttribution
public String getAttribution()fetchTile
public void fetchTile(int z, int x, int y, TileCallback callback)z/x/y, delivering the result to callback on
the event dispatch thread.