Skip to content

hersle/leaflet-route-print

Repository files navigation

Leaflet-route-print

Screenshot

leaflet-route-print is a Leaflet-plugin to print routes. It features an algorithm that finds a sequence of rectangles of a given size that fully cover the route and automatically prints them to a PDF file.

Demonstration

Visit hersle.github.io/leaflet-route-print or clone and run

./demo.sh

Usage and documentation

import * as L from "./leaflet.js";
import "./leaflet-route-print.js";

// Initialize and configure map
var map = L.map("map");
...

// Create route printing control and add it to the map
var routePrinter = new L.Control.PrintRouteControl();
routePrinter.addTo(map);

// Set the Leaflet Polyline to print
// IMPORTANT: elements to be included in the print must be rendered with Leaflet's Canvas renderer!
var line = L.polyline(..., {renderer: L.canvas()});
routePrinter.setRoute(line);

// Set the format of images in the generated PDF
routePrinter.setImageFormat("jpeg"); // very good quality, low file size (default)
routePrinter.setImageFormat("png");  // lossless quality, high file size

// Set the color and opacity of rectangles in the map that show the pages that will be printed
routePrinter.setFillColor("gray", 0.2);   // (default)
routePrinter.setStrokeColor("gray", 1.0); // (default)

About

A Leaflet plugin for easy client-side printing of routes

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages