Search code examples
angularjscesiumjs

How to take screenshot of map in CesiumJS?


I'm using CesuimJS (http://cesiumjs.org/) to present map. I want to take a screenshot of part of the map.

I tried using Three.js (http://learningthreejs.com/blog/2011/09/03/screenshot-in-javascript/) but failed to take a screenshot

Any ideas?


Solution

  • There is no need to use ThreeJS.

    You can use the canvas function toDataUrl.

    viewer.render();
    viewer.canvas.toDataUrl();
    

    toDataUrl returns url that can be used to get the screenshot.