TransWikia.com

Open Layers 4.0.1 Pausing Marker Animation?

Geographic Information Systems Asked by misman on June 26, 2021

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?

One Answer

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.

Correct answer by misman on June 26, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP