我正在使用Google Maps API V2来获取当前用户的位置,并使用onLocationChanged侦听器记录他的路线.当用户记录他们的路线时,我将在每个位置检测到的所有LatLng保存在一个arraylist中.当用户停止记录他们的路线时,我在arraylist的第一个点放置一个标记.我现在的问题是我希望通过arraylist中的所有点来设置标记的动画.有人可以告诉我,我该怎么做?
需要注意的是阵列不需要排序,因为我记录了它们来的点.我已经尝试使用for循环遍历数组并发送值,但是我得到了一个错误
final LatLng startLatLng = proj.fromScreenLocation(startPoint);
说"Unknown Source"和NullPointer异常.
这是我的代码:
case R.id.action_replay:
int o;
for(o=0; o<oldlocPoints.size(); ++o){
if(--o > 1){lastPos = oldlocPoints.get(--o);}
toPos = oldlocPoints.get(++o);
animateMarker(markerStart, lastPos, toPos);
}
return true;
Run Code Online (Sandbox Code Playgroud)
这就是我如何尝试通过标记进行动画制作.我遇到的主要困难是在run()中它似乎只是想要最终类型值,所以我不知道如何取悦它.
//Animates marker through the locations saved from the recorded route
public void animateMarker(final Marker marker, LatLng lastPos, final LatLng toPos) {
final long duration = 1600;
final Handler handler = new Handler();
this.lastPos = lastPos;
this.toPos = toPos;
final long start = SystemClock.uptimeMillis();
final int …Run Code Online (Sandbox Code Playgroud)