【发布时间】:2017-02-04 02:02:27
【问题描述】:
我正在尝试将标记从一个位置设置到另一个位置。为此,我使用 nutiteq 示例代码中的以下代码。
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
请告诉我上面的代码有什么问题?
【问题讨论】:
-
这段代码是做什么的,你希望它做什么?如果你能说出你的问题会更好:)
-
@JaakL 我正在尝试将标记从一个点移动到另一个点。我不想在更改位置时变得生涩。相反,它应该动画流畅。