m
maplibre-gl-export
Export map as PDF or images
Maintained by Water GIS
A MapLibre GL JS plugin to export the current map view as a PDF, PNG, JPEG, or SVG image with configurable DPI and page sizes.
Live demo
maplibre-gl-export running on MapLibre GL JS in your browser
Loading the map…
Demo code
import {
MaplibreExportControl,
Size,
PageOrientation,
Format,
DPI,
} from "@watergis/maplibre-gl-export";
import "@watergis/maplibre-gl-export/dist/maplibre-gl-export.css";
import type { PluginDemo } from "../types";
export default {
center: [11.576, 48.137], // Munich
zoom: 13,
run({ map, container }) {
map.addControl(
new MaplibreExportControl({
PageSize: Size.A4,
PageOrientation: PageOrientation.Landscape,
Format: Format.PNG,
DPI: DPI[96],
Crosshair: true,
PrintableArea: true,
Local: "en",
}),
"top-right",
);
// Open the export panel, which shows the crosshair and the printable area.
container.querySelector<HTMLButtonElement>(".maplibregl-export-control")?.click();
},
} satisfies PluginDemo;