How to download a map screenshot as a PNG file (screenshot helper)

This example shows how to download the current map view as a PNG file. The screenshot helper is the most convenient way to save map snapshots.

Getting a file directly is a nice option that can be useful to share some debugging context with colleagues, compare multiple styles, or share your creation on social media.

Click on the Take screenshot button to download a image for the current map view

NPM module setup


npm install --save @maptiler/sdk
import { Map, MapStyle, config, helpers } from '@maptiler/sdk';
import '@maptiler/sdk/dist/maptiler-sdk.css';

config.apiKey = 'YOUR_MAPTILER_API_KEY_HERE';
const map = new Map({
    container: 'map',
    zoom: 11,
    center: [0.66016, 42.62845],
    style: MapStyle.OUTDOOR
});

map.on('ready', () => {
  document.getElementById('screenshot').addEventListener('click', function () {
    helpers.takeScreenshot(map, {
      download: true,
      filename: "maptiler_map_screenshot.png"
    });
  });
});
How to take a screenshot of the current map view (screenshot helper)

Take screenshot (screenshot helper)

Examples

Capture map view as PNG blob using helper.

Heatmap layer (heatmap helper)

Heatmap layer (heatmap helper)

Examples

Quickly add a heatmap layer using the heatmap helper.

Point layer labels (point helper)

Point layer labels (point helper)

Examples

Add labeled point layer using MapTiler point helper.

Point layer scaled radius by property (point helper)

Point layer scaled radius by property (point helper)

Examples

Scale point layer radius and color by property.

Was this helpful?