com.google.android.gms.maps.model.Tile Java Examples

The following examples show how to use com.google.android.gms.maps.model.Tile. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TileProviderAndProjectionDemo.java    From android-maps-utils with Apache License 2.0 6 votes vote down vote up
@Override
public Tile getTile(int x, int y, int zoom) {
    Matrix matrix = new Matrix();
    float scale = (float) Math.pow(2, zoom) * mScale;
    matrix.postScale(scale, scale);
    matrix.postTranslate(-x * mDimension, -y * mDimension);

    Bitmap bitmap = Bitmap.createBitmap(mDimension, mDimension, Bitmap.Config.ARGB_8888);
    Canvas c = new Canvas(bitmap);
    c.setMatrix(matrix);

    for (Point p : mPoints) {
        c.drawCircle((float) p.x, (float) p.y, 1, new Paint());
    }

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
    return new Tile(mDimension, mDimension, baos.toByteArray());
}
 
Example #2
Source File: CompositeOverlay.java    From geopackage-android-map with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected Tile retrieveTile(int x, int y, int zoom) {
    Tile tile = null;
    for (BoundedOverlay overlay : overlays) {
        tile = overlay.retrieveTile(x, y, zoom);
        if (tile != null) {
            break;
        }
    }
    return tile;
}
 
Example #3
Source File: BoundedOverlay.java    From geopackage-android-map with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Tile getTile(int x, int y, int zoom) {

    Tile tile = null;

    // Check if there is a tile
    if (hasTile(x, y, zoom)) {

        // Retrieve the tile
        tile = retrieveTile(x, y, zoom);
    }

    return tile;
}
 
Example #4
Source File: GeoPackageOverlay.java    From geopackage-android-map with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Tile retrieveTile(int x, int y, int zoom) {

    GeoPackageTile geoPackageTile = retriever.getTile(x, y, zoom);
    Tile tile = GeoPackageOverlayFactory.getTile(geoPackageTile);

    return tile;
}
 
Example #5
Source File: XYZGeoPackageOverlay.java    From geopackage-android-map with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Tile retrieveTile(int x, int y, int zoom) {

    GeoPackageTile geoPackageTile = retriever.getTile(x, y, zoom);
    Tile tile = GeoPackageOverlayFactory.getTile(geoPackageTile);

    return tile;
}
 
Example #6
Source File: TileCoordinateDemoActivity.java    From android-samples with Apache License 2.0 5 votes vote down vote up
@Override
public Tile getTile(int x, int y, int zoom) {
    Bitmap coordTile = drawTileCoords(x, y, zoom);
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    coordTile.compress(Bitmap.CompressFormat.PNG, 0, stream);
    byte[] bitmapData = stream.toByteArray();
    return new Tile((int) (TILE_SIZE_DP * scaleFactor),
            (int) (TILE_SIZE_DP * scaleFactor), bitmapData);
}
 
Example #7
Source File: HeatmapTileProvider.java    From android-maps-utils with Apache License 2.0 5 votes vote down vote up
/**
 * helper function - convert a bitmap into a tile
 *
 * @param bitmap bitmap to convert into a tile
 * @return the tile
 */
private static Tile convertBitmap(Bitmap bitmap) {
    // Convert it into byte array (required for tile creation)
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
    byte[] bitmapdata = stream.toByteArray();
    return new Tile(TILE_DIM, TILE_DIM, bitmapdata);
}
 
Example #8
Source File: GeoPackageOverlayUtils.java    From geopackage-android-map with MIT License 3 votes vote down vote up
/**
 * Test overlay
 * 
 * @param geoPackage
 * @throws SQLException
 */
public static void testOverlay(GeoPackage geoPackage) throws SQLException {

	TileMatrixSetDao tileMatrixSetDao = geoPackage.getTileMatrixSetDao();

	if (tileMatrixSetDao.isTableExists()) {
		List<TileMatrixSet> results = tileMatrixSetDao.queryForAll();

		for (TileMatrixSet tileMatrixSet : results) {

			TileDao dao = geoPackage.getTileDao(tileMatrixSet);

			GeoPackageOverlay overlay = new GeoPackageOverlay(dao);

			for (int zoom = 0; zoom <= 21; zoom++) {
				int tileLength = (int) Math.pow(2, zoom);

				int column = (int) (Math.random() * tileLength);
				int row = (int) (Math.random() * tileLength);

				for (int maxColumns = Math.min(tileLength, column + 2); column < maxColumns; column++) {
					for (int maxRows = Math.min(tileLength, row + 2); row < maxRows; row++) {
						Tile tile = overlay.getTile(column, row, zoom);
						if (tile != null) {
							TestCase.assertTrue(tile.height > 0);
							TestCase.assertTrue(tile.width > 0);
						}
					}
				}

			}

		}

	}

}
 
Example #9
Source File: BoundedOverlay.java    From geopackage-android-map with MIT License 2 votes vote down vote up
/**
 * Retrieve the tile
 *
 * @param x    x coordinate
 * @param y    y coordinate
 * @param zoom zoom value
 * @return tile
 */
protected abstract Tile retrieveTile(int x, int y, int zoom);