How to take a screenshot of the current map view (screenshot helper)
This example shows how to capture the current map view as a blob
(PNG image). The screenshot helper is the most convenient way to save map snapshots.
The returned blob
of a PNG image file can be very handy if the goal is to programmatically further manipulate the screenshot, such as sending it to some feedback endpoint with a POST request.
In this example we are going to use the takeScreenshot
helper to replace the drawn map image (in the lower left corner of the map) with an image of the current map view.
Click on the Take screenshot button to replace the drawing map image for the current map view image
Related examples
An extension of MapLibre GL JS