Convert Map to Image or pdf

I want to convert the Map to an image or pdf, it is showing markers but the map is blank.
I am using Angular 8 and html2canvas and jspdf as libraries.

image

Hello,
We are looking into your issue. If possible, please, upload your code somewhere where we can look at it and investigate.

Hello,

There are two ways to approach this, depending on your exact use cases:

  1. First one - using html2canvas, just like you try. The whole trick is to use the idle event instead of load, as the load event is dispatched when all map resources are loaded, but not rendered yet. Here’s the code:
        var map = tt.map({
            key: 'YOUR_API_KEY',
            container: 'map',
        });

        map.on('idle', () => {
            html2canvas(document.body).then(function(canvas) {
                //the canvas here will contain images created from the map
            });
        });
  1. Second way of turning the map into an image does not require any library. But the drawback is that all the HTML overlays like controls or markers are not included (not sure if you need them in your use case). Here, you have to enable the preserveDrawingBuffer flag when initiating the map:
        var map = tt.map({
            key: 'YOUR_API_KEY',
            container: 'map',
            preserveDrawingBuffer: true
        });

        map.on('idle', () => {
            var canvas = map.getCanvas();
            var image = new Image();
            image.src = canvas.toDataURL("image/png");
        });