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

flyTo animation finishes after specified duration; pitch is not used #1429

Closed
perliedman opened this issue Aug 14, 2015 · 8 comments · Fixed by #1771
Closed

flyTo animation finishes after specified duration; pitch is not used #1429

perliedman opened this issue Aug 14, 2015 · 8 comments · Fixed by #1771

Comments

@perliedman
Copy link

I'm using flyTo method in a pretty basic example with mapbox-gl 0.9.0:

  var map = new mapboxgl.Map({
      container: 'map', // container id
      style: 'https://www.mapbox.com/mapbox-gl-styles/styles/outdoors-v7.json', //stylesheet location
      center: [40, -74.50], // starting position
      zoom: 9 // starting zoom
    });

  map.on('style.load', function() {
    var d = 5000,
        t = new Date().getTime();
    map.flyTo({
      center: [57.736, 11.94],
      pitch: 80,
      bearing: 90,
      duration: d,
      zoom: 50
    });
    map.once('moveend', function() {
      alert('we\'re done after ' + (new Date().getTime() - t));
    });
  });

I find two issues:

  1. although duration is specified as 5000 milliseconds, the map very, very slowly rotates to the specified bearing, and I get the alert after 22 or 23 seconds instead of expected 5
  2. the map is not pitched at all even when the animation has finished, although specified

From the docs (https://www.mapbox.com/mapbox-gl-js/api/#map/flyto), it appears that both duration and pitch should be supported, since they are part of CameraOptions, but perhaps this isn't entirely true for flyTo?

@perliedman
Copy link
Author

Made a jsfiddle to illustrate the issue described: http://jsfiddle.net/k8fkosxc/

@perliedman
Copy link
Author

Figured out that my setting of zoom to a much higher value than maxZoom. However, setting zoom to 20, the animation still takes 10 seconds to finish (twice the provided duration).

@jczaplew
Copy link
Contributor

I'm interested in making the pitch option work properly when using flyTo - is there anywhere that I could start to debug this or otherwise assist?

@lucaswoj
Copy link
Contributor

I can confirm that this bug still exists in v0.11.3 http://jsfiddle.net/9je928c5/

@jczaplew Does easeTo work for your use case? That does support pitch.

@lucaswoj
Copy link
Contributor

:foot-in-mouth: #1744

@lucaswoj
Copy link
Contributor

As a note, there are two separate, perhaps related, bugs being discussed here:

  • the flyTo bearing animation extends beyond the specified duration under some conditions
  • flyTo does not change the pitch if other parameters are set

@lucaswoj
Copy link
Contributor

lucaswoj commented Dec 1, 2015

the flyTo bearing animation extends beyond the specified duration under some conditions

My mistake. flyTo does not accept a duration parameter, only speed. Sorry for not catching that sooner! If you require an explicit duration, please use easeTo instead.

flyTo does not change the pitch if other parameters are set

Pushing a fix for this shortly 👍

@1ec5
Copy link
Contributor

1ec5 commented Dec 18, 2015

Filed #1854 to expose a duration option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants