The Wayback Machine - https://web.archive.org/web/20201018093700/https://github.com/maptalks/maptalks.js/issues/851
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AnimationTo can create bearing changes of almost a full circle when changing around 180 and -180 degrees. #851

Open
31415tertje opened this issue Jan 9, 2019 · 8 comments

Comments

@31415tertje
Copy link

@31415tertje 31415tertje commented Jan 9, 2019

maptalks's version used: 0.42.2, browser firefox or chrome

AnimationTo can create bearing changes of almost a full circle when changing around 180 and -180 degrees.

When I try to animate a route which goes from north to south, the bearing can change from around 180 to -180. e.g. a change from -178 to 177 is required which means a change of 5 degrees.
The animation is generating frames which go from -178 to 177 by positive increments of the bearing leading to a delta angle of 355 degrees instead of 5.

Please have a look of my proposed changes in Map.Anim.js which make sure the bearing change is always below 180 degrees,
Please have a look at my test html script which demonstrates the behaviour and works as expected after applying the proposed change.

Apart from this small bug, the library works extremely well and is easy to use. Thanks.

Map_Anim_js.zip



@fuzhenn
Copy link
Member

@fuzhenn fuzhenn commented Jan 10, 2019

Thanks!
I'll have a look into this later

@fuzhenn
Copy link
Member

@fuzhenn fuzhenn commented Jan 14, 2019

LGTM 👍 , could you submit a pull request?

@fuzhenn
Copy link
Member

@fuzhenn fuzhenn commented Jan 14, 2019

I have carefully reviewed your demo, the main concern of this proposal is:

If users want to intentionally rotate map with the angle diff > 180, they can never achieve it.

I think we should not change the bearing inside animateTo automatically which leads to ambiguousness, and should stick to a fixed logic, and let user decide bearing's value on the application level.

Get back to your demo, you can adjust bearings before passing to map.animateTo, this should be able to make it work rightly too.

@31415tertje
Copy link
Author

@31415tertje 31415tertje commented Jan 14, 2019

The problem of rotating almost 360 degrees only occurs when flipping from -180 to 180 or vice versa. In all other cases the rotation is always the shortest angle (< 180).
Can you really animate more than 180 degrees anywhere else?

Perhaps adding an extra option to animateTo would help:
direction: clockwise or anti clockwise.

Adjusting the bearings before passing to map.animateTo does not work (or I am doing it in a wrong way) since I start the next animation before the current one in ended. Doing this makes the route animation very fluent.

@fuzhenn
Copy link
Member

@fuzhenn fuzhenn commented Jan 14, 2019

Yes, a rotationDirection option is definitely a good idea. You can set this option to keep map's rotation direction right.

Could you have a test to see if it works?

@31415tertje
Copy link
Author

@31415tertje 31415tertje commented Jan 14, 2019

I'm not sure what you mean with 'Could you have a test to see if it works'.

  1. Adapt the code myself and test it.
  2. You adapt (or adapted) the code and I test it.

As far as I'm concerned rotationDirection would be:
clockwise, anticlockwise, shortestAngle
or
left, right, shortestAngle.

@fuzhenn
Copy link
Member

@fuzhenn fuzhenn commented Jan 14, 2019

1 will be great!

I prefer clockwise, anticlockwise, shortestAngle.

@31415tertje
Copy link
Author

@31415tertje 31415tertje commented Jan 14, 2019

Okay,

Please give me some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
You can’t perform that action at this time.