1/** 2 * @file Hack that resizes the map to 640x360 and prints it. Otherwise, the map isn't centered properly 3 */ 4 5/** 6 * Resizes map for printing 7 * @param {Object} map - Mapbox map 8 */ 9export function print(map) { 10 // Print hack 11 // https://github.com/crabbly/Print.js/issues/348#issuecomment-668007372 12 13 let focuser = setInterval(() => { 14 window.dispatchEvent(new Event('focus')); 15 }, 1000); 16 17 const container = document.querySelector('.locator__map'); 18 container.classList.remove('locator__no-print'); 19 20 container.style.width = '640px'; 21 container.style.height = '360px'; 22 23 map.resize(); 24 //To control styles from application end 25 document.body.classList.add('mapbox-locator'); 26 27 window.addEventListener('afterprint', (event) => { 28 clearInterval(focuser); 29 30 const container = document.querySelector('.locator__map'); 31 container.classList.add('locator__no-print'); 32 33 container.style.width = '100%'; 34 container.style.height = '100%'; 35 36 document.body.classList.remove('mapbox-locator'); 37 map.resize(); 38 }); 39 40 setTimeout(function () { 41 window.print(); 42 }, 1000); 43}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.