opensciencemap / vtm

a vector-tile map library written in java - running on android, desktop and within the browser
GNU Lesser General Public License v3.0
238 stars 176 forks source link

map Animator and manually setting viewport position are in conflict #98

Open MarsVard opened 10 years ago

MarsVard commented 10 years ago

I'm trying to have the compass update the map orientation while animating the maplocation to the user's gps location.

I'm setting the map orientation by doing Map.viewport().setRotation(...); and I try to use the Animator to fly to the user's location, but it seems like the 2 are in conflict because the animator implicitly tries to alter the rotation.

I think the animator class should definitely have some more options so we can se what should be animated and what not

by looking at the animateTo method I can see you're passing all flags to the animateStart method ANIM_MOVE | ANIM_SCALE | ANIM_ROTATE | ANIM_TILT, there should be an option to choose which flags are passed

public synchronized void animateTo(long duration, MapPosition pos) {
    mMap.getMapPosition(mStartPos);

    pos.scale = clamp(pos.scale,
                      Viewport.MIN_SCALE,
                      Viewport.MAX_SCALE);

    mDeltaPos.set(pos.x - mStartPos.x,
                  pos.y - mStartPos.y,
                  pos.scale - mStartPos.scale,
                  pos.bearing - mStartPos.bearing,
                  clamp(pos.tilt, 0, Viewport.MAX_TILT) - mStartPos.tilt);

    animStart(duration, ANIM_MOVE | ANIM_SCALE | ANIM_ROTATE | ANIM_TILT);
}
hjanetzek commented 10 years ago

At the moment the animation is canceled in updateAnimation whenever the Viewports MapPosition was changed outside the animator, so just passing flags for which value to be animated would not help. Maybe it suffices to move the cancellation to Map.setMapPosition and add an animateTo with ANIM_* flags parameter. In general the Animator needs improvement, but I dont have time to look into this currently.

MarsVard commented 10 years ago

Thanks for the tip @hjanetzek I'll try to play around with it myself if I have time over the weekend...