0

When I learned View Animation of OpenLayers I encountered a part of the code that I did not understand.

The source address is http://openlayers.org/en/latest/examples/animation.html.

  function flyTo(location, done) {
    var duration = 2000;
    var zoom = view.getZoom();
    var parts = 2;
    var called = false;
    function callback(complete) {
      --parts;
      if (called) {
        return;
      }
      if (parts === 0 || !complete) {
        called = true;
        done(complete);
      }
    }
    view.animate({
      center: location,
      duration: duration
    }, callback);
    view.animate({
      zoom: zoom - 1,
      duration: duration / 2
    }, {
      zoom: zoom,
      duration: duration / 2
    }, callback);
  }

What does "parts" and "called" mean? I changed "parts" value to 1 or 3 and did not see any change. It could also execute this method when I deleted the "callback".

1

callback is an optional so you don't need to pass it.
Then 'parts' and 'called' is not about OpenLayers.

  • 1
    What I want to know is their role in this place. – Epulari Sep 10 '17 at 2:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.