New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Request] Screenshot capture with preserveDrawingBuffer: false #2766
Comments
The answer to the SO post asserts that it's possible to get the drawing buffer without |
Here is a way of grabbing a screenshot when preserveDrawingBuffer is function takeScreenshot(map) {
return new Promise(function(resolve, reject) {
map.once("render", function() {
resolve(map.getCanvas().toDataURL());
});
/* trigger render */
map.setBearing(map.getBearing());
})
}
/* example */
takeScreenshot(map).then(function(data){
console.log(data);
}) |
@fxi Thanks for the great solution. I had to trigger the render a bit differently, by using I used a different method because I'm not sure if that's the best way to do it, so if anyone has a better way of triggering the render please let me know 😊 |
(and still making map downloads work by applying the trick from mapbox/mapbox-gl-js#2766 (comment))
@ofeka I used the |
Hey,
it is currently possible to grab screenshots of the map to a dataURI while
preserveDrawingBuffer
is set totrue
. As noted in the documentation, this comes at a performance cost – and it is very noticeable on mobile devices (A Galaxy S3 drops to roughly 50% of regular FPS with this flag enabled).It is apparently possible to grab screenshots of WebGL canvases without preserving the drawing buffer. See this stackoverflow:
http://stackoverflow.com/questions/30628064/how-to-toggle-preservedrawingbuffer-in-three-js
Would be great is mapbox-gl-js followed this implementation to get around the performance overhead of
preserveDrawingBuffer
.The text was updated successfully, but these errors were encountered: