Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map download #5

Open
eltonteb opened this issue Mar 29, 2024 · 3 comments
Open

Map download #5

eltonteb opened this issue Mar 29, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@eltonteb
Copy link

Facility to be able to get a PDF of a map of the annotations in a document

@rsimon rsimon added the enhancement New feature or request label Mar 29, 2024
@rsimon
Copy link
Member

rsimon commented Apr 3, 2024

A full solution for this will remain out of reach for the foreseeable future, I'm afraid. It would require a bigger investment. Both in terms of development time, as well as with regard to maintaining it as a production setup (see below).

A smaller, limited solution, however, is possible: I managed to get halfway decent results with the html2canvas JavaScript library. With some limitations, html2canvas allows you to create programmatic screenshots in the browser. See, for example this actual screenshot...

Bildschirmfoto 2024-04-03 um 16 00 52

...and the programmatic rendering, a PNG file generated with html2canvas for just the map element.

filename (5)

I think this is a reasonable workaround for now. But keep in mind that html2canvas is limited to generating an image exactly as things appear in the browser. That includes properties such as same aspect ratio and (more or less) resolution. I believe enhancements would be possible. (Such as opening another much larger Leaflet map in an offscreen page element, and then letting html2canvas render a "screenshot" of this element instead.) But this would take more work & experimentation.

Notes on a server-side solution: a full solution for producing a print-quality image, with user-configurable size/aspect ratio would likely involve a server-based solution. The server would have to run something like headless Chrome, which could then generate large raster images, based on a set of input parameters (map base-layer, map bounds, GeoJSON data overlay, etc.) After rendering the high-res raster image, exporting it to different formats (JPG, PDF, etc.) would be the easy part.

Overall, development effort for such a solution would be much more significant, and deployment & maintenance of the combined system would become more complex.

@rsimon
Copy link
Member

rsimon commented Apr 3, 2024

P.S.: the PNG screenshot feature is now available on the test instance.

@rsimon
Copy link
Member

rsimon commented Apr 4, 2024

Update: html2canvas will only work if map tiles are fetched with a specific HTTP setting. This setting is now enabled in the geotagger plugin.

However, with this setting enabled, map tiles are only displayed if, in turn, the tile server explicitly allows cross-domain requests (by setting the appropriate HTTP header in their responses: Access-Control-Allow-Origin: *). This is typically the case for open tile servers (OpenStreetMap, Digital Atlas of the Roman Empire, etc.)

The CAWM tile server, however, does not have this setting enabled. This means their map tiles now show blank in the Recogito user interface. I have therefore removed CAWM from the list of pre-set basemap choices.

@eltonteb: do you have any active contacts at the CAWM? If so, we could ask them if they can enable the Access-Control-Allow-Origin: * HTTP response header on their end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants