/** * Sets the tile source for this tile provider. * * @param pTileSource the tile source */ public void setTileSource(final ITileLayer pTileSource) { if (mTileSource != null) { mTileSource.detach(); } mTileSource = pTileSource; if (mTileSource != null) { mCacheKey = mTileSource.getCacheKey(); } }
/** * Get the tile provider bounding box. * * @return the tile source bounding box */ public BoundingBox getBoundingBox() { return mTileSource.getBoundingBox(); }
/** * Get the tile provider center. * * @return the tile source center */ public LatLng getCenterCoordinate() { return mTileSource.getCenterCoordinate(); }
@Override public void detach() { if (getTileSource() != null) { getTileSource().detach(); } synchronized (mTileProviderList) { for (final MapTileModuleLayerBase tileProvider : mTileProviderList) { tileProvider.detach(); } } synchronized (mWorking) { mWorking.clear(); } }
/** * Get the tile size in pixels this tile provider provides. * * @return the tile size in pixels */ public int getTileSizePixels() { return mTileSource.getTileSizePixels(); }
/** * Gets the minimum zoom level this tile provider can provide * * @return the minimum zoom level */ public float getMinimumZoomLevel() { return mTileSource.getMinimumZoomLevel(); }
/** * Get the tile provider suggested starting zoom. * * @return the tile suggested starting zoom */ public float getCenterZoom() { return mTileSource.getCenterZoom(); }
/** * Get the maximum zoom level this tile provider can provide. * * @return the maximum zoom level */ public float getMaximumZoomLevel() { return mTileSource.getMaximumZoomLevel(); }
public void addTileSource(final ITileLayer pTileSource, final int index) { if (pTileSource == null) { return; } final MapTileDownloader downloaderProvider = new MapTileDownloader(pTileSource, mTileCache, mNetworkAvailabilityCheck, mMapView); if (hasNoSource()) { mCacheKey = pTileSource.getCacheKey(); } synchronized (mTileProviderList) { if (index < 0 || index > mTileProviderList.size()) { return; } mTileProviderList.add(index, downloaderProvider); } }
@Override public void detach() { if (getTileSource() != null) { getTileSource().detach(); } if (offlineMapDatabase != null) { offlineMapDatabase.closeDatabase(); } } }
/** * Draw a 'loading' placeholder with a canvas. */ private SafePaint getLoadingTilePaint() { if (mLoadingTilePaint == null && mLoadingBackgroundColor != Color.TRANSPARENT) { try { final int tileSize = mTileProvider.getTileSource() != null ? mTileProvider.getTileSource() .getTileSizePixels() : 256; mLoadingTileBitmap = Bitmap.createBitmap(tileSize, tileSize, Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(mLoadingTileBitmap); canvas.drawColor(mLoadingBackgroundColor); final int lineSize = tileSize / 16; for (int a = 0; a < tileSize; a += lineSize) { canvas.drawLine(0, a, tileSize, a, mLoadingPaint); canvas.drawLine(a, 0, a, tileSize, mLoadingPaint); } mLoadingTilePaint = new SafePaint(); mLoadingTilePaint.setShader(new BitmapShader(mLoadingTileBitmap, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT)); } catch (final OutOfMemoryError e) { Log.e(TAG, "OutOfMemoryError getting loading tile: " + e.toString()); System.gc(); } } return mLoadingTilePaint; }