zskarte / zskarte-client

Zivilschutz-Karte allows to draw situation maps for disaster management
https://www.zskarte.ch/
MIT License
13 stars 8 forks source link

feat(print): add pdf generation logic #404

Open swerder opened 4 months ago

swerder commented 4 months ago

This implements / fixes: https://github.com/zskarte/zskarte-client/issues/259

It is based on changes from https://github.com/zskarte/zskarte-client/pull/400

The QR-Code deeplinks only work together with https://github.com/zskarte/zskarte-client/pull/405

The new print sidebar is shown by clicking on "Print" menu point in menu sidebar or if the user presses Ctrl+P / Meta+P or the Browser Print function is called from menu. In the last case the browser print view is still shown (cannot be bypassed). Pressing Esc closes now any sidebar.

The attribution was missed for OSM Tiles, I added them. Also updated the attribution on other layers to work and match the ones in geoAdmin Layers. The attribution was not shown on the page, I added the corresponding ol-component, and move it to "center bottom" of the view. Based on the logic the sidebar goes "over" the map and not change the size of it, it's not optically center if an sidebar is open. This sidebar behavior was also the reason I had to move it to center because it would not be visible otherwise.

I need to add crossOrigin: 'anonymous', to all tile layers/sources because otherwise the canvas was "tainted" and could not be exported anymore.

I added an global css class like-mat-form-field-outline to be used with fieldset to have the same border style for radioGroup and checkboxes as for other input fields.

The option emptyMap and the available paperFormat allow to use the print/pdf function also to create maps for drawing physically on it (up to A0), a feature our ZSO miss on all other online map/mapping tools...

Normal mode is to allow user to select the area to print(click on the map), and based on the other options the corresponding scale is calculated. It is also possible to select an specific scale in the dropdown. sidebar-print component_autoscale

While printing the map interactions are deactivated to prevent interrupting the print view settings. While printing there is also a progress bar, showing progress of loading needed tiles (0-80%) and do the other pdf generation work.(80-100%)

sidebar-print component_progress

And "direct print" function as mentioned in issue is not implemented, as this have no added value than use the print on the directly opened pdf.

example pdf: Druck Test Operation_A5.pdf