Package 

Class MapTileProviderBase

  • 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
    see MapTileIndex for an overview of how tiles are served by this provider.
    • 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
      • 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 object
        pDrawable - 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 object
        pDrawable - the Drawable of the map tile
      • 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 now
        pOldZoomLevel - the previous zoom level that we should get the tiles to rescale
        pViewPort - the view port we need tiles for
      • 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.