From 288f97605d0af8b027fbfc16703ce4856176dd8c Mon Sep 17 00:00:00 2001 From: hellekin Date: Sun, 31 Jan 2021 19:06:53 +0100 Subject: [FEATURE] Add print button Using `leaflet-easyprint`, we can add a button to print a current view of the map. This commit adds the functionality, without customization. Source: https://github.com/rowanwins/leaflet-easyPrint --- app/javascript/controllers/map_controller.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'app') diff --git a/app/javascript/controllers/map_controller.js b/app/javascript/controllers/map_controller.js index 005599e..57bafa5 100644 --- a/app/javascript/controllers/map_controller.js +++ b/app/javascript/controllers/map_controller.js @@ -18,6 +18,7 @@ import "leaflet-providers" import "leaflet.markercluster/dist/leaflet.markercluster.js" import 'leaflet-extra-markers' +import 'leaflet-easyprint' export default class extends Controller { static targets = [ "container" ] @@ -65,6 +66,15 @@ export default class extends Controller { L.DomEvent.on(window, 'hashchange', this.doSomethingCool); + /* Show a button to print the map */ + L.easyPrint({ + title: 'Print this map', + position: 'bottomright', + filename: `incommon-map-detail`, + exportOnly: true, + sizeModes: ['A4Portrait', 'A4Landscape'] + }).addTo(this.map); + // Allow calling the mapController from elsewhere. this.element[this.identifier] = this } -- cgit v1.2.3