Wednesday 14 February 2018

javascript - View Animation of OpenLayers


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




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...