diff options
author | hellekin <hellekin@cepheide.org> | 2021-01-31 19:06:53 +0100 |
---|---|---|
committer | hellekin <hellekin@cepheide.org> | 2021-01-31 20:18:53 +0100 |
commit | 288f97605d0af8b027fbfc16703ce4856176dd8c (patch) | |
tree | d9cb3fec7feac32e02c22aacdc17c8e54930aef3 /app | |
parent | fa9e4ea45d75e3e6c72ab51aa6e19b212e25ff60 (diff) | |
download | incommon-map-288f97605d0af8b027fbfc16703ce4856176dd8c.tar.gz |
[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
Diffstat (limited to 'app')
-rw-r--r-- | app/javascript/controllers/map_controller.js | 10 |
1 files changed, 10 insertions, 0 deletions
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 } |