I implemented heremaps in an angular app and use it to print a PDF using wkhtmltopdf, the problem is that I need to have a reliable event to listen to in order to inform wkhtmltopdf that my map is fully loaded and ready to be printed. Specifically some tiles are either not loaded or still in a blur state when printing the PDF.
I tried to listen to the mapviewchangeend
event, but it isn't thrown at tile loading. I also tried listening to the render
event of the rendering engine but an event is thrown each time a tile is loaded and I don't know exactly how many tiles I am supposed to wait
// add a listener on the map ready event
this.map.getEngine().addEventListener("render", (event: H.util.Event) => {
if (this.map.getEngine() === event.target) {
map.mapReadyAction();
}
});
Is there a reliable way to know when my map tiles are fully loaded and ready to be printed ?
edit: using the post linked in the comments I found a way to reliably count the number of loaded tiles. Unfortunately I can't find a way to determine the total number of tiles my map needs to load (getTileNumber()
in the code)
this.nbLoadedTiles = 0;
this.map
.getBaseLayer()
.getProvider()
.addEventListener("update", () => {
this.nbLoadedTiles++;
console.log(`tile loaded : ${this.nbLoadedTiles}`);
if (this.nbLoadedTiles === this.getTileNumber()) {
console.log("All tiles loaded");
map.mapReadyAction();
this.nbLoadedTiles = 0;
}
});
Thanks !