Nutiteq 3D SDK上的动画标记

时间:2015-10-20 13:04:53

标签: android nutiteq

我正在尝试将标记从一个位置设置为另一个位置。为此,我使用了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

请告诉我上述代码有什么问题?

1 个答案:

答案 0 :(得分:1)

您正在使用适用于SDK 2.x的代码段。您也可以将它用于SDK 3.x,但您需要更改以下行

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

PropertyValuesHolder markerLocationPVHolder = PropertyValuesHolder.ofKeyframe("pos", markerLocationKeyframes);
相关问题