1

I am using open layers 4. I am moving and stoping marker animation as this example without any problem. But I want to add pause and continue functionality to marker also. I edit some variables and endeavor on the issue with these functions. But elapsedTime is negative on moveFeature function continuously.

 function pauseAnimation() {
            animating = false;
            //I hold elapsed time globally
            var index = Math.round($("[id='rightfrm:tbv1:txt1']").val() * elapsedTime / 1000);
            (geoMarker.getGeometry()).setCoordinates(line_coordinates[index].lc);
            map.un('postcompose', moveFeature);
        }

 function continueAnimation() {
    animating = true;
    now = new Date().getTime();
    now = now - 10000 + elapsedTime; // --10000-- for negativeness
    geoMarker.setStyle(null);
    map.on('postcompose', moveFeature);
    map.render();
 }

How should I add pause and continue functionality?

1

I found my problem. It was a logical error. Pause and Continue working now

now = new Date().getTime() - elapsedTime;

Anyone can use these functions for Pause/Continue functionality.

  • I'm also using same functionality.. Based on Animation speed, feature point should travel speed or fast.. replayIndex = Math.round(speed * elapsedTime / 1000); – Venkat Maridu May 3 '17 at 9:15

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.