Eddie-Larsson / mapbox-print-pdf

A library for saving high resolution versions of mapbox-gl maps to a pdf with an optional header and/or footer that scales with the size of the format.
https://eddie-larsson.github.io/mapbox-print-pdf/
MIT License
51 stars 17 forks source link

The load event in mapbox fires before everything has been rendered. #1

Open Eddie-Larsson opened 6 years ago

Eddie-Larsson commented 6 years ago

As stated the 'load' event for the rendered map is fired before everything has been properly rendered, resulting in missing features in the image. Current workaround is to listen for the 'render' event and wait in intervals of 500 milliseconds, if no render event happened during that time the map is considered done.

This is undesirable for a multitude of reasons but the primary problem is that the "fix" might fail horribly under some condition such as poor network connectivity or possibly even a slow machine.

Possibly related are the following mapbox-gl -js issues 1, 2.

sebastianovide commented 6 years ago

we are displaying an historical sequence of maps and therefore we need to know when to hide layers (when the new one is fully rendered)... What would be the best way of doing it ? (waiting few times half a second seams a lot...)

Eddie-Larsson commented 6 years ago

@sebastianovide Beats me, the best way I've found is the one described above. If I knew of a better way I'd be using it.