A Minimal Leaflet App That’s Print-Friendly
Leaflet is small, readable, and ideal for simple maps. This guide shows a minimal setup with vector overlays and styles that hold up when you print or export.
Core ideas
- Use vector layers (GeoJSON) for crisp lines.
- Keep stroke widths light and fills semi-transparent.
- Preview at the final orientation before exporting.
Minimal structure
<div id="map"></div>
<script src="https://unpkg.com/leaflet/dist/leaflet.js"></script>
<script>
// init
const map = L.map('map').setView([51.5, -0.1], 12);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',{
maxZoom:19, attribution:'© OSM'
}).addTo(map);
// vector overlay
const geojson = {"type":"FeatureCollection","features":[ /* your features */ ]};
L.geoJSON(geojson,{
style: {color:'#000', weight:2, opacity:1, fillOpacity:0.4}
}).addTo(map);
</script>
Print tips
- Use landscape for wider extents; portrait for corridors.
- Test grayscale readability if the printer isn’t color-calibrated.
- For final output, annotate and export via TrueGIS using Scaled Print.
Also see: Leaflet vs OpenLayers and Prepare GeoJSON for TrueGIS.