我正在从缓存向Google地图添加多个TileOverlay。当尝试通过更改其可见性使用处理程序为它们设置动画时,在第一次播放期间地图上的叠加层会闪烁。
我可以通过其他任何方式实现这一目标吗?
public class LocalTileProvider implements TileProvider {
private String url;
DatabaseHelper db;
String type;
// private Paint opacityPaint = new Paint();
String newurl= PathFinder.rainradar_HDBaseurl;
String uid;
public LocalTileProvider(String uid,DatabaseHelper cache,String type){
this.uid=uid;
this.db=cache;
this.type=type;
}
//taking the tile from SQLITEDATABASE
@Override
public Tile getTile(int x, int y, int zoom){
Tile tile = null;
if(db.ispresent(uid, zoom,x , y,type)){
byte[] b=db.gettiles(uid, zoom,x , y,type);
tile = new Tile(256, 256, b);
return tile;
}
return NO_TILE;
}
}
以下是将这些图块添加到Google地图的代码
LocalTileProvider provider1 = new LocalTileProvider(uidList.get(0), db, TAG);
TileOverlayOptions top1 = new TileOverlayOptions().tileProvider(provider1).visible(true);
tileoverlay_1 = googleMap.addTileOverlay(top1);
添加它们之后,我通过切换磁贴的可见性来使用处理程序播放动画
public void start() {
btn_play.setEnabled(true);
tileoverlay_default.setVisible(false);
runnable_animation = new Runnable() {
@Override
public void run() {
//tileoverlay_default.setVisible(false);
isDownloading = false;
// stop_download=true;
isRunning = true;
btn_play.setBackgroundResource(R.drawable.player_pause_2x);
setVisibility(global);
if (global == 11) {
global = 0;
} else {
global = global + 1;
}
mHandler_animation.postDelayed(this, 1000);
}
};
mHandler_animation.post(runnable_animation);
}
答案 0 :(得分:0)
public class LocalTileProvider implements TileProvider
{
private String url;
DatabaseHelper db;
String type;
// private Paint opacityPaint = new Paint();
String newurl= PathFinder.rainradar_HDBaseurl;
String uid;
public LocalTileProvider(String uid,DatabaseHelper cache,String type)
{
this.uid=uid;
this.db=cache;
this.type=type;
}
//taking the tile from SQLITEDATABASE
@Override
public Tile getTile(int x, int y, int zoom)
{
Tile tile = null;
if(db.ispresent(uid, zoom,x , y,type))
{
byte[] b=db.gettiles(uid, zoom,x , y,type);
tile = new Tile(256, 256, b);
return tile;
}
return NO_TILE;
}
}
答案 1 :(得分:0)
Gmaps总是有一些" filckering"添加新的TileOverlay时。 您有两种选择:
答案 2 :(得分:0)
我知道这是一个非常老的问题,但是如果有人在寻找该问题的答案,我想我可以发表我的答案。
将TileOverlay添加到地图时,其闪烁有两个原因。
从代码的外观来看,您正在缓存磁贴,因此,要阻止它们闪烁,您需要做的就是关闭淡入行为:
var filedb = SpreadsheetApp.create("FileDBValueYourTime")
var folder = DriveApp.createFolder("ValueYourTime")
var idfolder = folder.getId()
var idfile = filedb.getId()
var movefile = DriveApp.getFileById(idfile)
folder.addFile(movefile)
//save ID file and folder
var scriptProperties = PropertiesService.getScriptProperties();
scriptProperties.setProperty('FILEID', idfile)
scriptProperties.setProperty('FOLDERID', idfolder)