여러 마커가있는 Google지도를 만듭니다. 이제 해당 마커 사이에서 자동차 아이콘을 이동하고 싶습니다.이 Move markers in google map v2 androidGoogle지도의 위치 목록이있는 경우 한 위치에서 다른 위치로 마커를 이동하는 방법 android
나는 첫 번째 지점에서 두 번째 지점 사이에서 자동차 아이콘을 움직일 수있다. 그러나 두 번째에서 세 번째로 움직이지 않는다. 내가 이것을 위해 루프에 사용했을 때 그것은 최종 지점으로 간절히 간다. 나는 지연도 추가했지만 다른 것은 나를 위해 일했다. .
미리 감사드립니다.
이
내 코드 ::이다public void setAnimation(GoogleMap myMap, final List<LatLng> directionPoint) {
anim_map = myMap;
anim_marker = myMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_icon))
.position(directionPoint.get(0))
.flat(true));
myMap.animateCamera(CameraUpdateFactory.newLatLngZoom(directionPoint.get(0), 10));
if (directionPoint.size() >= 2) {
for (int i = 0; i < directionPoint.size() - 1; i++) {
h.post(new Runnable() {
@Override
public void run() {
animateMarker(anim_map, anim_marker, directionPoint, false);
}
});
}
}
}
private void animateMarker(GoogleMap myMap, final Marker marker, final List<LatLng> directionPoint,
final boolean hideMarker) {
final long start = SystemClock.uptimeMillis();
final long duration = 350000;
final Interpolator interpolator = new LinearInterpolator();
h.post(new Runnable() {
int i = 0;
@Override
public void run() {
long elapsed = SystemClock.uptimeMillis() - start;
float t = interpolator.getInterpolation((float) elapsed
/duration);
// Log.e("T Location", t + "");
double lng = t * directionPoint.get(i + 1).longitude + (1 - t) * directionPoint.get(i).longitude;
double lat = t * directionPoint.get(i + 1).latitude + (1 - t) * directionPoint.get(i).latitude;
marker.setPosition(new LatLng(lat, lng));
if (t < 1.0) {
h.postDelayed(this, 1);
} else {
if (hideMarker) {
marker.setVisible(false);
} else {
marker.setVisible(true);
}
}
}
});
}
난 내가 inc를 할 때 내 문제는,이 천천히 움직이지됩니다 point.But는 목적지로 이동합니다 내가 값을 증가 올바른 positions.If를 얻을 난 내가 처음부터 응용 프로그램을 열 value.When 수 있습니다 시간 자체가 끝났어. 나는 그것을 볼 수 없다. – Punithapriya
내가 이해하는 한, 값을 하드 코딩하는 경우 루프에서 지연을 넣어야합니다. 예 : 10 초. 그럼 너는 볼 수있을거야. – Stallion
예 지연도 추가되었지만 작동하지 않습니다. – Punithapriya