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".

asked Mar 15, 2017 at 2:52

1 Answer 1

1

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

answered Apr 27, 2017 at 4:07
1
  • 1
    What I want to know is their role in this place. Commented Sep 10, 2017 at 2:59

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.