public class

TileLayer

extends Layer
java.lang.Object
   ↳ com.carto.layers.Layer
     ↳ com.carto.layers.TileLayer
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

An abstract base class for all tile layers.

Summary

Public Methods
MapTile calculateMapTile(MapPos mapPos, int zoom)
Calculates the tile corresponding to given geographical coordinates and zoom level.
MapBounds calculateMapTileBounds(MapTile mapTile)
Calculates the bounds of given map tile.
MapPos calculateMapTileOrigin(MapTile mapTile)
Calculates the origin of given map tile.
void clearTileCaches(boolean all)
Clears layer tile caches.
synchronized void delete()
TileDataSource getDataSource()
Returns the data source assigned to this layer.
int getFrameNr()
Returns the current frame number.
int getMaxOverzoomLevel()
Gets the current maximum overzoom level for this layer.
int getMaxUnderzoomLevel()
Gets the current maximum underzoom level for this layer.
TileLoadListener getTileLoadListener()
Returns the tile load listener.
TileSubstitutionPolicy getTileSubstitutionPolicy()
Returns the current tile substitution policy.
TileDataSource getUTFGridDataSource()
Returns the tile data source of the associated UTF grid.
UTFGridEventListener getUTFGridEventListener()
Returns the UTF grid event listener.
float getZoomLevelBias()
Gets the current zoom level bias for this layer.
boolean isPreloading()
Returns the state of the preloading flag of this layer.
boolean isSynchronizedRefresh()
Returns the state of the synchronized refresh flag.
boolean isUpdateInProgress()
Tests whether this layer is being currently updated.
void setFrameNr(int frameNr)
Sets the frame number, only used for animated tiles.
void setMaxOverzoomLevel(int overzoomLevel)
Sets the maximum overzoom level for this layer.
void setMaxUnderzoomLevel(int underzoomLevel)
Sets the maximum underzoom level for this layer.
void setPreloading(boolean preloading)
Sets the state of preloading for this layer.
void setSynchronizedRefresh(boolean synchronizedRefresh)
Sets the state of the synchronized refresh flag.
void setTileLoadListener(TileLoadListener tileLoadListener)
Sets the tile load listener.
void setTileSubstitutionPolicy(TileSubstitutionPolicy policy)
Sets the current tile substitution policy.
void setUTFGridDataSource(TileDataSource dataSource)
Sets the tile data source of the associated UTF grid.
void setUTFGridEventListener(UTFGridEventListener utfGridEventListener)
Sets the UTF grid event listener.
void setZoomLevelBias(float bias)
Sets the zoom level bias for this layer.
[Expand]
Inherited Methods
From class com.carto.layers.Layer
From class java.lang.Object

Public Methods

public MapTile calculateMapTile (MapPos mapPos, int zoom)

Calculates the tile corresponding to given geographical coordinates and zoom level.
Note: zoom level bias is NOT applied, only discrete zoom level is used.

Parameters
mapPos Coordinates of the point in data source projection coordinate system.
zoom Zoom level to use for the tile.
Returns
  • The corresponding map tile.

public MapBounds calculateMapTileBounds (MapTile mapTile)

Calculates the bounds of given map tile.

Parameters
mapTile The map tile to use.
Returns
  • The corresponding bounds of the tile origin in data source projection coordinate system.

public MapPos calculateMapTileOrigin (MapTile mapTile)

Calculates the origin of given map tile.

Parameters
mapTile The map tile to use.
Returns
  • The corresponding coordinates of the tile origin in data source projection coordinate system.

public void clearTileCaches (boolean all)

Clears layer tile caches. This will release memory allocated to tiles.

Parameters
all True if all tiles should be released, otherwise only preloading (invisible) tiles are released.

public synchronized void delete ()

public TileDataSource getDataSource ()

Returns the data source assigned to this layer.

Returns
  • The tile data source assigned to this layer.

public int getFrameNr ()

Returns the current frame number.

Returns
  • The current frame number.

public int getMaxOverzoomLevel ()

Gets the current maximum overzoom level for this layer.

Returns
  • The current maximum overzoom level for this layer.

public int getMaxUnderzoomLevel ()

Gets the current maximum underzoom level for this layer.

Returns
  • The current maximum underzoom level for this layer.

public TileLoadListener getTileLoadListener ()

Returns the tile load listener.

Returns
  • The tile load listener.

public TileSubstitutionPolicy getTileSubstitutionPolicy ()

Returns the current tile substitution policy.

Returns
  • The current substitution policy. Default is TILE_SUBSTITUTION_POLICY_ALL.

public TileDataSource getUTFGridDataSource ()

Returns the tile data source of the associated UTF grid. By default this is null.

Returns
  • The tile data source of the associated UTF grid.

public UTFGridEventListener getUTFGridEventListener ()

Returns the UTF grid event listener.

Returns
  • The UTF grid event listener.

public float getZoomLevelBias ()

Gets the current zoom level bias for this layer.

Returns
  • The current zoom level bias for this layer.

public boolean isPreloading ()

Returns the state of the preloading flag of this layer.

Returns
  • True if preloading is enabled.

public boolean isSynchronizedRefresh ()

Returns the state of the synchronized refresh flag.

Returns
  • The state of the synchronized refresh flag.

public boolean isUpdateInProgress ()

Tests whether this layer is being currently updated.

Returns
  • True when the layer is being updated or false when the layer is in steady state.

public void setFrameNr (int frameNr)

Sets the frame number, only used for animated tiles.
Loading a new frame may take some time, previous frame is shown during loading.

Parameters
frameNr The frame number to display.

public void setMaxOverzoomLevel (int overzoomLevel)

Sets the maximum overzoom level for this layer.
If a tile for the given zoom level Z is not available, SDK will try to use tiles with zoom levels Z-1, ..., Z-MaxOverzoomLevel.
The default is 6.

Parameters
overzoomLevel The new maximum overzoom value.

public void setMaxUnderzoomLevel (int underzoomLevel)

Sets the maximum underzoom level for this layer.
If a tile for the given zoom level Z is not available, SDK will try to use tiles with zoom levels Z-1, ..., Z-MaxOverzoomLevel and then Z+1, ..., Z+MaxUnderzoomLevel.
The default is 3.

Parameters
underzoomLevel The new maximum underzoom value.

public void setPreloading (boolean preloading)

Sets the state of preloading for this layer. Preloading allows the downloading of tiles that are not
currently visible on screen, but are adjacent to ones that are. This means that the user can pan the map without
immediately noticing any missing tiles.

Enabling this option might introduce a small performance hit on slower devices. It should also be noted that this
will considerably increase network traffic if used with online maps. The default is false.

Parameters
preloading The new preloading state of the layer.

public void setSynchronizedRefresh (boolean synchronizedRefresh)

Sets the state of the synchronized refresh flag. If disabled all tiles will appear on screen
one by one as they finish loading. If enabled the map will wait for all the visible tiles to finish loading
and then show them all on screen together. This is useful for animated tiles.

Parameters
synchronizedRefresh The new state of the synchronized refresh flag.

public void setTileLoadListener (TileLoadListener tileLoadListener)

Sets the tile load listener.

Parameters
tileLoadListener The tile load listener.

public void setTileSubstitutionPolicy (TileSubstitutionPolicy policy)

Sets the current tile substitution policy.

Parameters
policy The new substitution policy. Default is TILE_SUBSTITUTION_POLICY_ALL.

public void setUTFGridDataSource (TileDataSource dataSource)

Sets the tile data source of the associated UTF grid.

Parameters
dataSource The data source to use. Can be null if UTF grid is not used.

public void setUTFGridEventListener (UTFGridEventListener utfGridEventListener)

Sets the UTF grid event listener.

Parameters
utfGridEventListener The UTF grid event listener.

public void setZoomLevelBias (float bias)

Sets the zoom level bias for this layer.
Higher zoom level bias forces SDK to use more detailed tiles for given view compared to lower zoom bias.
The default bias is 0.

Parameters
bias The new bias value, both positive and negative fractional values are supported.