2015-10-20 57 views
1

我正在嘗試將標記從一個位置動畫到另一個位置。爲此,我使用nutiteq示例代碼中的以下代碼。Nutiteq 3D SDK上的動畫標記

MapPos markerLocation0 = baseProjection.fromWgs84(currentBlueDotPostion); 
MapPos markerLocation1 = baseProjection.fromWgs84(toPosition); 
Keyframe[] markerLocationKeyframes = new Keyframe[] { 
    Keyframe.ofObject(0.0f, markerLocation0), 
    Keyframe.ofObject(1.0f, markerLocation1) 
}; 

// Create property values holder for "mapPos" property and set custom evaluator for MapPos type 
PropertyValuesHolder markerLocationPVHolder = PropertyValuesHolder.ofKeyframe("mapPos", markerLocationKeyframes); 
markerLocationPVHolder.setEvaluator(new TypeEvaluator() { 
    public Object evaluate(float fraction, Object startValue, Object endValue) { 
     MapPos pos0 = (MapPos) startValue; 
     MapPos pos1 = (MapPos) endValue; 
     return new MapPos(pos0.getX() + (pos1.getX() - pos0.getX()) * fraction, pos0.getY() + (pos1.getY() - pos0.getY()) * fraction); 
    } 
}); 

final ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(userPostionMarker, markerLocationPVHolder); 
animator.setDuration(2000); // duration 2000ms 
// Make it to bounce 
animator.setInterpolator(new AccelerateInterpolator()); 
animator.start(); 

https://github.com/nutiteq/hellomap3d/wiki/Animated-marker

請讓我知道什麼是與上面的代碼的問題?

+0

而這是什麼代碼做的,你的願望,它呢?這將是更好的,如果你會告訴你的問題:) – JaakL

+0

@JaakL我想從一個點到另一個標記的動畫..我不想當更改位置生澀。相反,它應該順利進行動畫。 – Fahim

回答

1

您正在使用適用於SDK 2.x的代碼片段。你可以使用它的SDK 3.x中也有,但是你需要下面一行

PropertyValuesHolder markerLocationPVHolder = PropertyValuesHolder.ofKeyframe("mapPos", markerLocationKeyframes); 

更改爲線

PropertyValuesHolder markerLocationPVHolder = PropertyValuesHolder.ofKeyframe("pos", markerLocationKeyframes);