Class HttpTileSource
- All Implemented Interfaces:
TileSource
- Direct Known Subclasses:
MvtTileSource, 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).
-
Constructor Summary
ConstructorsConstructorDescriptionHttpTileSource(String urlTemplate, boolean vector, int minZoom, int maxZoom) Creates an HTTP tile source. -
Method Summary
Modifier and TypeMethodDescriptionvoidfetchTile(int z, int x, int y, TileCallback callback) Requests the tile atz/x/y, delivering the result tocallbackon the event dispatch thread.Attribution text that must be displayed over the map.intThe largest zoom level this source serves.intThe smallest zoom level this source serves.intThe tile edge in pixels (almost always 256).booleanisVector()True for MVT vector tiles, false for raster image tiles.Sets the API key substituted into the{key}token of the template.setAttribution(String attribution) Sets the attribution string shown over the map.
-
Constructor Details
-
HttpTileSource
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
Sets the API key substituted into the{key}token of the template. -
setAttribution
Sets the attribution string shown over the map. -
isVector
public boolean isVector()True for MVT vector tiles, false for raster image tiles.- Specified by:
isVectorin interfaceTileSource
-
getTileSize
public int getTileSize()The tile edge in pixels (almost always 256).- Specified by:
getTileSizein interfaceTileSource
-
getMinZoom
public int getMinZoom()The smallest zoom level this source serves.- Specified by:
getMinZoomin interfaceTileSource
-
getMaxZoom
public int getMaxZoom()The largest zoom level this source serves.- Specified by:
getMaxZoomin interfaceTileSource
-
getAttribution
Attribution text that must be displayed over the map.- Specified by:
getAttributionin interfaceTileSource
-
fetchTile
Requests the tile atz/x/y, delivering the result tocallbackon the event dispatch thread.- Specified by:
fetchTilein interfaceTileSource
-