@Override public int getMaximumZoomLevel() { ITileSource tileSource = mTileSource.get(); return tileSource != null ? tileSource.getMaximumZoomLevel() : microsoft.mappoint.TileSystem.getMaximumZoomLevel(); }
@Override public boolean onCreateOptionsMenu( final Menu pMenu, final int pMenuIdOffset, final MapView pMapView) { final SubMenu mapMenu = pMenu .addSubMenu(0, MENU_MAP_MODE + pMenuIdOffset, Menu.NONE, R.string.map_mode) .setIcon(R.drawable.ic_menu_mapmode); for (int a = 0; a < TileSourceFactory.getTileSources().size(); a++) { final ITileSource tileSource = TileSourceFactory.getTileSources().get(a); mapMenu.add( MENU_MAP_MODE + pMenuIdOffset, MENU_TILE_SOURCE_STARTING_ID + a + pMenuIdOffset, Menu.NONE, tileSource.name()); } mapMenu.setGroupCheckable(MENU_MAP_MODE + pMenuIdOffset, true, true); if (ctx != null) { final String title = ctx.getString( pMapView.useDataConnection() ? R.string.set_mode_offline : R.string.set_mode_online); final Drawable icon = ctx.getResources().getDrawable(R.drawable.ic_menu_offline); pMenu.add(0, MENU_OFFLINE + pMenuIdOffset, Menu.NONE, title).setIcon(icon); } return true; }
@Override public int getMinimumZoomLevel() { ITileSource tileSource = mTileSource.get(); return tileSource != null ? tileSource.getMinimumZoomLevel() : OpenStreetMapTileProviderConstants.MINIMUM_ZOOMLEVEL; }
@Override public boolean onCreateOptionsMenu(final Menu pMenu) { pMenu.add(0, MENU_ZOOMIN_ID, Menu.NONE, "ZoomIn"); pMenu.add(0, MENU_ZOOMOUT_ID, Menu.NONE, "ZoomOut"); final SubMenu subMenu = pMenu.addSubMenu(0, MENU_TILE_SOURCE_ID, Menu.NONE, "Choose Tile Source"); { for (final ITileSource tileSource : TileSourceFactory.getTileSources()) { subMenu.add( 0, 1000 + tileSource.ordinal(), Menu.NONE, tileSource.localizedName(mResourceProxy)); } } pMenu.add(0, MENU_ANIMATION_ID, Menu.NONE, "Run Animation"); pMenu.add(0, MENU_MINIMAP_ID, Menu.NONE, "Toggle Minimap"); return true; }
@Override public Drawable loadTile(final MapTileRequestState pState) { ITileSource tileSource = mTileSource.get(); if (tileSource == null) { return null; } final MapTile pTile = pState.getMapTile(); // if there's no sdcard then don't do anything if (!getSdCardAvailable()) { if (OpenStreetMapTileProviderConstants.DEBUGMODE) { Log.d(IMapView.LOGTAG, "No sdcard - do nothing for tile: " + pTile); } return null; } InputStream inputStream = null; try { if (OpenStreetMapTileProviderConstants.DEBUGMODE) { Log.d(IMapView.LOGTAG, "Tile doesn't exist: " + pTile); } inputStream = getInputStream(pTile, tileSource); if (inputStream != null) { if (OpenStreetMapTileProviderConstants.DEBUGMODE) { Log.d(IMapView.LOGTAG, "Use tile from archive: " + pTile); } final Drawable drawable = tileSource.getDrawable(inputStream); return drawable; } } catch (final Throwable e) { Log.e(IMapView.LOGTAG, "Error loading tile", e); } finally { if (inputStream != null) { StreamUtils.closeStream(inputStream); } } return null; }
public byte[] getImage(final ITileSource pTileSource, final MapTile pTile) { try { byte[] bits = null; final String[] tile = {COLUMN_TILE}; final long x = (long) pTile.getX(); final long y = (long) pTile.getY(); final long z = (long) pTile.getZoomLevel(); final long index = ((z << z) + x << z) + y; final Cursor cur = mDatabase.query( TABLE, tile, COLUMN_KEY + " = " + index + " and " + COLUMN_PROVIDER + " = '" + pTileSource.name() + "'", null, null, null, null); if (cur.getCount() != 0) { cur.moveToFirst(); bits = (cur.getBlob(0)); } cur.close(); if (bits != null) { return bits; } } catch (final Throwable e) { Log.w(IMapView.LOGTAG, "Error getting db stream: " + pTile, e); } return null; }
@Override public int getMaximumZoomLevel() { return mTileSource != null ? mTileSource.getMaximumZoomLevel() : MINIMUM_ZOOMLEVEL; }