Zaczero / openstreetmap-ng

🚀 The Next Generation of OpenStreetMap — in Python!
GNU Affero General Public License v3.0
102 stars 10 forks source link

Export sidebar: support PDF and SVG types #36

Open starsep opened 2 weeks ago

starsep commented 2 weeks ago

I noticed that export to PDF and SVG does not work. On Firefox it exports to PNG. Short-term I would suggest to hide those options and add TODOs in the code.

Canvas.toBlob() api is used with mimetype: https://github.com/Zaczero/openstreetmap-ng/blob/8c6aa73486d50f2248a1c8b31b98c759465ad751/app/static/js/leaflet/_image-export.js#L174 On https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob I don't see any mentioned support of PDF/SVG. I think this feature makes mostly sense for raster graphics considering that raster tiles are joined.

OSM offloads hardwork to https://render.openstreetmap.org/. PDF is not just embedded png there: text is selectable for example.

Related TODO: https://github.com/Zaczero/openstreetmap-ng/blob/4ae2d74fe36bf077a18049297d21b84ff032d632/app/static/js/leaflet/_sidebar-share.js#L262

PS Perhaps this issue can be splitted to two: PDF/SVG if implementation will be different.

Zaczero commented 2 weeks ago

The SVG/PDF fallback should use the https://render.openstreetmap.org/ service. This seems to be the simplest way to get SVG/PDF files.