-
- All Implemented Interfaces:
-
org.osmdroid.tileprovider.IMapTileProviderCallback
public abstract class MapTileProviderBase implements IMapTileProviderCallback
This is an abstract class. The tile provider is responsible for:
- determining if a map tile is available,
- notifying the client, via a callback handler
-
-
Field Summary
Fields Modifier and Type Field Description public final static intMAPTILE_SUCCESS_IDpublic final static intMAPTILE_FAIL_ID
-
Constructor Summary
Constructors Constructor Description MapTileProviderBase(ITileSource pTileSource)MapTileProviderBase(ITileSource pTileSource, Handler pDownloadFinishedListener)
-
Method Summary
Modifier and Type Method Description abstract DrawablegetMapTile(long pMapTileIndex)Attempts to get a Drawable that represents a MapTileIndex. voiddetach()classes that extend MapTileProviderBase must call this method to prevent memory leaks.Updated 5. static voidsetApproximationBackgroundColor(int pColor)Sets the default color for approximated tiles. abstract intgetMinimumZoomLevel()Gets the minimum zoom level this tile provider can provide abstract intgetMaximumZoomLevel()Gets the maximum zoom level this tile provider can provide voidsetTileSource(ITileSource pTileSource)Sets the tile source for this tile provider. ITileSourcegetTileSource()Gets the tile source for this tile provider. MapTileCachecreateTileCache()Creates a MapTileCache to be used to cache tiles in memory. voidsetTileLoadFailureImage(Drawable drawable)Sets the "sorry we can't load a tile for this location" image. voidmapTileRequestCompleted(MapTileRequestState pState, Drawable pDrawable)Called by implementation class methods indicating that they have completed the request asbest it can. voidmapTileRequestFailed(MapTileRequestState pState)Called by implementation class methods indicating that they have failed to retrieve therequested map tile. voidmapTileRequestFailedExceedsMaxQueueSize(MapTileRequestState pState)Called by implementation class methods indicating that they have failed to retrieve therequested map tile, because the max queue size has been reached voidmapTileRequestExpiredTile(MapTileRequestState pState, Drawable pDrawable)Called by implementation class methods indicating that they have produced an expired resultthat can be used but better results may be delivered later. voidsetTileRequestCompleteHandler(Handler handler)Collection<Handler>getTileRequestCompleteHandlers()voidensureCapacity(int pCapacity)MapTileCachegetTileCache()voidclearTileCache()purges the cache of all tiles (default is the in memory cache) booleanuseDataConnection()Whether to use the network connection if it's available. voidsetUseDataConnection(boolean pMode)Set whether to use the network connection if it's available. voidrescaleCache(Projection pProjection, double pNewZoomLevel, double pOldZoomLevel, Rect pViewPort)Recreate the cache using scaled versions of the tiles currently in it abstract IFilesystemCachegetTileWriter()abstract longgetQueueSize()voidexpireInMemoryCache(long pMapTileIndex)Expire a tile that is in the memory cacheTypical use is for mapsforge, where the contents of the tile can evolve,depending on the neighboring tiles that have been displayed so far. -
Methods inherited from class org.osmdroid.tileprovider.IMapTileProviderCallback
mapTileRequestCompleted, mapTileRequestExpiredTile, mapTileRequestFailed, mapTileRequestFailedExceedsMaxQueueSize -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
MapTileProviderBase
MapTileProviderBase(ITileSource pTileSource)
-
MapTileProviderBase
MapTileProviderBase(ITileSource pTileSource, Handler pDownloadFinishedListener)
-
-
Method Detail
-
getMapTile
abstract Drawable getMapTile(long pMapTileIndex)
Attempts to get a Drawable that represents a MapTileIndex. If the tile is not immediatelyavailable this will return null and attempt to get the tile from known tile sources forsubsequent future requests. Note that this may return a ReusableBitmapDrawable inwhich case you should follow proper handling procedures for using that Drawable or it mayreused while you are working with it.
-
detach
void detach()
classes that extend MapTileProviderBase must call this method to prevent memory leaks.Updated 5.2+
-
setApproximationBackgroundColor
static void setApproximationBackgroundColor(int pColor)
Sets the default color for approximated tiles.
- Parameters:
pColor- the default color that will be shown for approximated tiles
-
getMinimumZoomLevel
abstract int getMinimumZoomLevel()
Gets the minimum zoom level this tile provider can provide
-
getMaximumZoomLevel
abstract int getMaximumZoomLevel()
Gets the maximum zoom level this tile provider can provide
-
setTileSource
void setTileSource(ITileSource pTileSource)
Sets the tile source for this tile provider.
- Parameters:
pTileSource- the tile source
-
getTileSource
ITileSource getTileSource()
Gets the tile source for this tile provider.
-
createTileCache
MapTileCache createTileCache()
Creates a MapTileCache to be used to cache tiles in memory.
-
setTileLoadFailureImage
void setTileLoadFailureImage(Drawable drawable)
Sets the "sorry we can't load a tile for this location" image. If it's null, the default viewis shown, which is the standard grey grid controlled by the tiles overlay setLoadingLineColor and setLoadingBackgroundColor
-
mapTileRequestCompleted
void mapTileRequestCompleted(MapTileRequestState pState, Drawable pDrawable)
Called by implementation class methods indicating that they have completed the request asbest it can. The tile is added to the cache, and a MAPTILE_SUCCESS_ID message is sent.
- Parameters:
pState- the map tile request state objectpDrawable- the Drawable of the map tile
-
mapTileRequestFailed
void mapTileRequestFailed(MapTileRequestState pState)
Called by implementation class methods indicating that they have failed to retrieve therequested map tile. a MAPTILE_FAIL_ID message is sent.
- Parameters:
pState- the map tile request state object
-
mapTileRequestFailedExceedsMaxQueueSize
void mapTileRequestFailedExceedsMaxQueueSize(MapTileRequestState pState)
Called by implementation class methods indicating that they have failed to retrieve therequested map tile, because the max queue size has been reached
- Parameters:
pState- the map tile request state object
-
mapTileRequestExpiredTile
void mapTileRequestExpiredTile(MapTileRequestState pState, Drawable pDrawable)
Called by implementation class methods indicating that they have produced an expired resultthat can be used but better results may be delivered later. The tile is added to the cache,and a MAPTILE_SUCCESS_ID message is sent.
- Parameters:
pState- the map tile request state objectpDrawable- the Drawable of the map tile
-
setTileRequestCompleteHandler
@Deprecated() void setTileRequestCompleteHandler(Handler handler)
-
getTileRequestCompleteHandlers
Collection<Handler> getTileRequestCompleteHandlers()
-
ensureCapacity
void ensureCapacity(int pCapacity)
-
getTileCache
MapTileCache getTileCache()
-
clearTileCache
void clearTileCache()
purges the cache of all tiles (default is the in memory cache)
-
useDataConnection
boolean useDataConnection()
Whether to use the network connection if it's available.
-
setUseDataConnection
void setUseDataConnection(boolean pMode)
Set whether to use the network connection if it's available.
- Parameters:
pMode- if true use the network connection if it's available.
-
rescaleCache
void rescaleCache(Projection pProjection, double pNewZoomLevel, double pOldZoomLevel, Rect pViewPort)
Recreate the cache using scaled versions of the tiles currently in it
- Parameters:
pNewZoomLevel- the zoom level that we need nowpOldZoomLevel- the previous zoom level that we should get the tiles to rescalepViewPort- the view port we need tiles for
-
getTileWriter
abstract IFilesystemCache getTileWriter()
-
getQueueSize
abstract long getQueueSize()
-
expireInMemoryCache
void expireInMemoryCache(long pMapTileIndex)
Expire a tile that is in the memory cacheTypical use is for mapsforge, where the contents of the tile can evolve,depending on the neighboring tiles that have been displayed so far.
-
-
-
-