答案 0 :(得分:0)
在此简短剪辑中,进度标记(围绕标记的一系列8个圆)以一个填充的圆圈前进,表示进度-基于任何进度计算需要(在这种情况下,需要5个位置更新,但很可能会完成距离)。
标记图标是完整的东西(汽车+标记针+进度圈),并且在9个文件中重复了该图标,更改了进度圈。
如果感兴趣,我可以发布详细信息,但摘要为:
.setPosition()
,标记就会随位置一起移动。以下是提供的示例的处理程序实现:
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
boolean onOff = false;
@Override
public void run() {
// imageId is set in the onLocationChanged based on 'progress'
// determination - 0/8 complete; 1/8 complete...
int currentImageId = imageId;
// icons is an array list populated at initialization with
// BitmapDescriptors from resources - one for each progress
// fraction (0 - 8).
BitmapDescriptor currentIcon = icons.get(currentImageId);
// Flashing results from using the "0-progress" indicator icon
// which is at index 0.
BitmapDescriptor offIcon = icons.get(0);
if (onOff) {
marker1.setIcon(offIcon);
} else {
marker1.setIcon(currentIcon);
}
onOff = !onOff;
// restart handler timer.
handler.postDelayed(this, 500);
}
}, 100);
图标列表的初始化如下:
// repeat for all progress images
final BitmapDescriptor icon0 = BitmapDescriptorFactory.fromResource(R.drawable.car0);
// and add to list
final ArrayList<BitmapDescriptor> icons = new ArrayList<>();
// repeat for all progress images
icons.add(icon0);
定制来自“进度确定”-如果沿着路线行驶,则在onLocationChanged
中计算路径完成率,并将其应用于最大图像数量,以产生上述imageId
。如:
int imageId = pathCompleteRatio * maxImages;