1

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?

Fahim
  • 12,198
  • 5
  • 39
  • 57
  • And what does this code do, and what you wish that it does? It would be better if you would tell what is your issue :) – JaakL Oct 20 '15 at 14:27
  • @JaakL I am trying to animate the marker from one point to another.. i dont want to be jerky when changed the location. Instead it should animate smoothly. – Fahim Oct 20 '15 at 14:34

1 Answers1

1

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);
MarkT
  • 301
  • 2
  • 2