Unable to openlayer3 Export PDF

Asked 1 years ago, Updated 1 years ago, 38 views

The openlayer3 Export PDF output wait state does not end.
With the intention of creating PDF output of the map using http://openlayers.org/en/latest/examples/export-pdf.html, I copied and almost made a sample of this openlayer3.
However, it works by copying it locally, but zoom in
After a few clicks of the Export PDF button, the system is in a waiting state and does not exit.If you zoom in or out while waiting (mouse cursor changes),
Start moving.
There may have been a mistake when I copied it locally, so I did the same thing at the above URL and reproduced it, so I think it was a problem from the beginning.
I can't find a strong way even if I look it up online.
After a little research with Firefox debugger,
map.getView().fit(extent,(map.getSize()));
This is what happens when the server does not receive a request.
Unable to find the ol3api document for .fit.
Please let me know if you know the workaround.

javascript

2022-09-30 21:19

1 Answers

Note (18/8/22): An event called rendercomplete has been added that fires after reading and drawing with or without cache.The sample you mentioned has also been modified to use it, so continuous clicks on the Export PDF button will work.

まだ It has only been merged into the master branch, so I think the release will be around v5.2.0.

Add'rendercomplete' event by ahocevar ·Pull Request #8532 ·openlayers/openlayers

The general outline of the sample is as follows:

In the case in question, there is no tileload event indicating tile loading status, and it seems to stop waiting for tile loading 3.I guess this event will not occur for tiles that have already been loaded and cached.

I found workarounds such as:

  • Using the postrender event instead of the tile loading event
  • postcomposeIf tileloadstart does not occur after a certain period of time after the event, it is determined that everything has been loaded and moved to PDF generation
  • Use source.refresh() within the event to force tiles to load

The first method also eliminates the need for tile read management. However, the postrender event does not get the <canvas> element, and should be combined with other events

Ensering all tiles are loaded in Open Layers 3XYZ source-Stack Overflow


2022-09-30 21:19

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.