I have a logo (logoContainer) on top of my map, that i need to include in the print:

      mapboxgl.accessToken = '<ACCESS TOKEN>';;

      var map = new mapboxgl.Map({
        container: 'map', // container id
        style: ''mapbox://styles/mapbox/streets-v11'',
        center: [-74.5, 40],
        zoom: 5, 
        preserveDrawingBuffer: true

      var logoContainer = document.getElementById("logoContainer");


I can simply get the image of the map on click, but this will of course not give me my logo container on top:

$('#printButton').click(function () {
var img = new Image();
var mapCanvas = document.querySelector('.mapboxgl-canvas');
img.src = mapCanvas.toDataURL();

I need something like L.easyprint html2canvas mess up when you scroll away from map. Contruction the link with Mapbox static map does (of course) not give the logocontainer either.

Any leads / solutions?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.