I am trying to animate the marker from one position to another. For this i am using the following code from the nutiteq sample code.
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
Please let me know what is the issue with the above code?
You are using snippet meant for SDK 2.x. You can use it for SDK 3.x also, but you need to change the following line
PropertyValuesHolder markerLocationPVHolder = PropertyValuesHolder.ofKeyframe("mapPos", markerLocationKeyframes);
to the line
PropertyValuesHolder markerLocationPVHolder = PropertyValuesHolder.ofKeyframe("pos", markerLocationKeyframes);