本文整理汇总了Java中com.google.android.gms.maps.model.Tile类的典型用法代码示例。如果您正苦于以下问题:Java Tile类的具体用法?Java Tile怎么用?Java Tile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Tile类属于com.google.android.gms.maps.model包,在下文中一共展示了Tile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCachedTile
import com.google.android.gms.maps.model.Tile; //导入依赖的package包/类
/**
* Load a tile from cache.
* Returns null if there is no corresponding cache entry or it could not be loaded.
*/
private Tile getCachedTile(String key) {
if (mCache.isClosed()) {
return null;
}
try {
DiskLruCache.Snapshot snapshot = mCache.get(key);
if (snapshot == null) {
// tile is not in cache
return null;
}
final byte[] data = readStreamAsByteArray(snapshot.getInputStream(INDEX_DATA));
final int height = readStreamAsInt(snapshot.getInputStream(INDEX_HEIGHT));
final int width = readStreamAsInt(snapshot.getInputStream(INDEX_WIDTH));
if (data != null) {
LOGD(TAG, "Cache hit for tile " + key);
return new Tile(width, height, data);
}
} catch (IOException e) {
// ignore error
}
return null;
}
示例2: cacheTile
import com.google.android.gms.maps.model.Tile; //导入依赖的package包/类
private boolean cacheTile(String key, Tile tile) {
if (mCache.isClosed()) {
return false;
}
try {
DiskLruCache.Editor editor = mCache.edit(key);
if (editor == null) {
// editor is not available
return false;
}
writeByteArrayToStream(tile.data, editor.newOutputStream(INDEX_DATA));
writeIntToStream(tile.height, editor.newOutputStream(INDEX_HEIGHT));
writeIntToStream(tile.width, editor.newOutputStream(INDEX_WIDTH));
editor.commit();
return true;
} catch (IOException e) {
// Tile could not be cached
}
return false;
}
示例3: onTransact
import com.google.android.gms.maps.model.Tile; //导入依赖的package包/类
public boolean onTransact(int paramInt1, Parcel paramParcel1, Parcel paramParcel2, int paramInt2)
{
switch (paramInt1)
{
default:
return super.onTransact(paramInt1, paramParcel1, paramParcel2, paramInt2);
case 1598968902:
paramParcel2.writeString("com.google.android.gms.maps.model.internal.ITileProviderDelegate");
return true;
}
paramParcel1.enforceInterface("com.google.android.gms.maps.model.internal.ITileProviderDelegate");
Tile localTile = a(paramParcel1.readInt(), paramParcel1.readInt(), paramParcel1.readInt());
paramParcel2.writeNoException();
if (localTile != null)
{
paramParcel2.writeInt(1);
localTile.writeToParcel(paramParcel2, 1);
return true;
}
paramParcel2.writeInt(0);
return true;
}
示例4: getCachedTile
import com.google.android.gms.maps.model.Tile; //导入依赖的package包/类
/**
* Load a tile from cache.
* Returns null if there is no corresponding cache entry or it could not be loaded.
*
* @param key
* @return
*/
private Tile getCachedTile(String key) {
try {
DiskLruCache.Snapshot snapshot = mCache.get(key);
if (snapshot == null) {
// tile is not in cache
return null;
}
final byte[] data = readStreamAsByteArray(snapshot.getInputStream(INDEX_DATA));
final int height = readStreamAsInt(snapshot.getInputStream(INDEX_HEIGHT));
final int width = readStreamAsInt(snapshot.getInputStream(INDEX_WIDTH));
if (data != null) {
LogUtils.LOGD(TAG, "Cache hit for tile " + key);
return new Tile(width, height, data);
}
} catch (IOException e) {
// ignore error
}
return null;
}
示例5: cacheTile
import com.google.android.gms.maps.model.Tile; //导入依赖的package包/类
private boolean cacheTile(String key, Tile tile) {
try {
DiskLruCache.Editor editor = mCache.edit(key);
if (editor == null) {
// editor is not available
return false;
}
writeByteArrayToStream(tile.data, editor.newOutputStream(INDEX_DATA));
writeIntToStream(tile.height, editor.newOutputStream(INDEX_HEIGHT));
writeIntToStream(tile.width, editor.newOutputStream(INDEX_WIDTH));
editor.commit();
return true;
} catch (IOException e) {
// Tile could not be cached
}
return false;
}
示例6: getCachedTile
import com.google.android.gms.maps.model.Tile; //导入依赖的package包/类
/**
* Load a tile from cache.
* Returns null if there is no corresponding cache entry or it could not be loaded.
*
* @param key
* @return
*/
private Tile getCachedTile(String key) {
try {
DiskLruCache.Snapshot snapshot = mCache.get(key);
if (snapshot == null) {
// tile is not in cache
return null;
}
final byte[] data = readStreamAsByteArray(snapshot.getInputStream(INDEX_DATA));
final int height = readStreamAsInt(snapshot.getInputStream(INDEX_HEIGHT));
final int width = readStreamAsInt(snapshot.getInputStream(INDEX_WIDTH));
if (data != null) {
LOGD(TAG, "Cache hit for tile " + key);
return new Tile(width, height, data);
}
} catch (IOException e) {
// ignore error
}
return null;
}
示例7: onTransact
import com.google.android.gms.maps.model.Tile; //导入依赖的package包/类
public boolean onTransact(int paramInt1, Parcel paramParcel1, Parcel paramParcel2, int paramInt2)
{
switch (paramInt1)
{
default:
break;
case 1598968902:
paramParcel2.writeString("com.google.android.gms.maps.model.internal.ITileProviderDelegate");
return true;
case 1:
paramParcel1.enforceInterface("com.google.android.gms.maps.model.internal.ITileProviderDelegate");
Tile localTile = getTile(paramParcel1.readInt(), paramParcel1.readInt(), paramParcel1.readInt());
paramParcel2.writeNoException();
if (localTile != null)
{
paramParcel2.writeInt(1);
localTile.writeToParcel(paramParcel2, 1);
}
else
{
paramParcel2.writeInt(0);
}
return true;
}
return super.onTransact(paramInt1, paramParcel1, paramParcel2, paramInt2);
}
示例8: getTile
import com.google.android.gms.maps.model.Tile; //导入依赖的package包/类
public Tile getTile(int paramInt1, int paramInt2, int paramInt3)
{
Parcel localParcel1 = Parcel.obtain();
Parcel localParcel2 = Parcel.obtain();
try
{
localParcel1.writeInterfaceToken("com.google.android.gms.maps.model.internal.ITileProviderDelegate");
localParcel1.writeInt(paramInt1);
localParcel1.writeInt(paramInt2);
localParcel1.writeInt(paramInt3);
this.dU.transact(1, localParcel1, localParcel2, 0);
localParcel2.readException();
Tile localTile;
if (localParcel2.readInt() != 0)
localTile = Tile.CREATOR.createFromParcel(localParcel2);
else
localTile = null;
return localTile;
}
finally
{
localParcel2.recycle();
localParcel1.recycle();
}
}
示例9: getTile
import com.google.android.gms.maps.model.Tile; //导入依赖的package包/类
@Override
public Tile getTile(int x, int y, int z) {
// query the provider for a tile specified by x, y and z coordinates
String[] projection = new String[]{TilesContract.COLUMN_TILE_DATA};
String selection = TilesContract.COLUMN_ZOOM_LEVEL + " = ? AND "
+ TilesContract.COLUMN_TILE_COLUMN + "= ? AND "
+ TilesContract.COLUMN_TILE_ROW + "= ?";
String[] selectionArgs = new String[]{String.valueOf(z), String.valueOf(x), String.valueOf((int) (Math.pow(2, z) - y - 1))};
// .mbtiles database use TSM coordinates
// we need to switch to Google compatible coordinates
// https://gist.github.com/tmcw/4954720
Cursor cursor = mContext.getContentResolver().query(Uri.parse(mContentProviderPath), projection, selection, selectionArgs, null);
Tile tile = TileProvider.NO_TILE;
if (cursor.moveToFirst())
tile = cursorToMapItem(cursor);
// make sure to close the cursor
cursor.close();
return tile;
}
示例10: initialize
import com.google.android.gms.maps.model.Tile; //导入依赖的package包/类
public static synchronized void initialize(Context context) {
if (instance != null) {
throw new Error("attempted to initialize " + BackgroundTileProvider.class.getName() + " more than once");
}
InputStream in = null;
try {
in = context.getAssets().open("background_tile.png");
byte[] data = new byte[in.available()];
in.read(data);
tile = new Tile(TILE_WIDTH, TILE_HEIGHT, data);
}
catch (IOException e) {
throw new Error("failed to load offline tile asset", e);
}
finally {
if (in != null)
try { in.close(); }
catch (Exception ignored) {}
}
instance = new BackgroundTileProvider();
}
示例11: getTile
import com.google.android.gms.maps.model.Tile; //导入依赖的package包/类
@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());
}
示例12: onTransact
import com.google.android.gms.maps.model.Tile; //导入依赖的package包/类
public boolean onTransact(int paramInt1, Parcel paramParcel1, Parcel paramParcel2, int paramInt2)
{
switch (paramInt1)
{
default:
return super.onTransact(paramInt1, paramParcel1, paramParcel2, paramInt2);
case 1598968902:
paramParcel2.writeString("com.google.android.gms.maps.model.internal.ITileProviderDelegate");
return true;
case 1:
}
paramParcel1.enforceInterface("com.google.android.gms.maps.model.internal.ITileProviderDelegate");
Tile localTile = a(paramParcel1.readInt(), paramParcel1.readInt(), paramParcel1.readInt());
paramParcel2.writeNoException();
if (localTile != null)
{
paramParcel2.writeInt(1);
localTile.writeToParcel(paramParcel2, 1);
return true;
}
paramParcel2.writeInt(0);
return true;
}
示例13: getTile
import com.google.android.gms.maps.model.Tile; //导入依赖的package包/类
@Override
public Tile getTile(int x, int y, int zoom) {
Bitmap coorTile = drawTileCoors(x, y, zoom);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
coorTile.compress(Bitmap.CompressFormat.PNG, 0, stream);
byte[] bitmapData = stream.toByteArray();
return new Tile((int) (TILE_SIZE_DP * mScaleFactor),
(int) (TILE_SIZE_DP * mScaleFactor), bitmapData);
}
示例14: getTile
import com.google.android.gms.maps.model.Tile; //导入依赖的package包/类
@Override
public Tile getTile(int x, int y, int zoom) {
MapTile tile = new MapTile(zoom, x, y);
Bitmap bitmap = source.renderTile(tile);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] bitmapdata = stream.toByteArray();
return new Tile(512, 512, bitmapdata);
}
示例15: getTile
import com.google.android.gms.maps.model.Tile; //导入依赖的package包/类
@Override
public Tile getTile(int x, int y, int z) {
byte[] tileImage = getTileImage(x, y, z);
if (tileImage != null) {
return new Tile(mTileWidth / 2, mTileHeight / 2, tileImage);
}
return NO_TILE;
}