Lawrence
Lawrence

Reputation: 165

Remove Cesium's Camera Move Event Listener

I have the following event listener:

  viewer.camera.moveStart.addEventListener(function(removeextra) {
     // the camera started to move
     clearoriginal();
    });
viewer.camera.moveEnd.addEventListener(function(addback) {
     // the camera stopped moving

     getresults();

});

How can I remove these event listeners? I do not know the syntax.I tried with the following it does not work.

viewer.camera.moveStart.removeEventListener(removeextra);
      
viewer.camera.moveEnd.removeEventListener(addback);

Upvotes: 2

Views: 817

Answers (2)

Kinglish
Kinglish

Reputation: 23654

I looked into Cesium and I think you might rewrite them like this

viewer.camera.moveStart.addEventListener(clearoriginal);
viewer.camera.moveEnd.addEventListener(getresults);

// then to remove

viewer.camera.moveStart.removeEventListener(clearoriginal);
viewer.camera.moveEnd.removeEventListener(getresults);

Upvotes: 2

Ajay yadav
Ajay yadav

Reputation: 264

viewer.camera.moveEnd.removeEventListener('click', getresults,// pass the method which you add false );

addEventListener() and removeEventListener() are not present in older browsers. You can work around this by inserting the following code at the beginning of your scripts, allowing the use of addEventListener() and removeEventListener() in implementations that do not natively support it. However, this method will not work on Internet Explorer 7 or earlier, since extending the Element. a prototype was not supported until Internet Explorer 8.

Upvotes: 1

Related Questions