PageSourceSearch

https://yevwke.github.io/AzarMap/export-pdf.js?v=2

js yevwke.github.io collected 2026-10-03 10:13:06 UTC 2,840 bytes, 1 lines download raw bytes

1var W=1e4,H=5625,ZOOM=5,RES=2,TILE_SIZE=256,DRAW_SIZE=TILE_SIZE*RES,COLS=20,ROWS=11;function drawTiles(e){for(var t=[],n=0;n<ROWS;n++)for(var o=0;o<COLS;o++)(function(n,o){var a=new Promise(function(t){var a=new Image;a.onload=function(){e.drawImage(a,n*DRAW_SIZE,o*DRAW_SIZE,DRAW_SIZE,DRAW_SIZE),t()},a.onerror=function(){t()},a.src="tiles/"+ZOOM+"/"+n+"/"+o+".webp"});t.push(a)})(o,n);return Promise.all(t)}function loadFeatureIcons(e){var t=e.map(function(e){return new Promise(function(t){var n=new Image;n.onload=function(){e._pdfIcon=n,t()},n.onerror=function(){t()},n.src=e.get("icon")})});return Promise.all(t)}function drawIcons(e,t){t.forEach(function(t){if(t._pdfIcon){var n=t.getGeometry().getCoordinates(),o=t._pdfIcon,a=1.08*o.naturalWidth,r=1.08*o.naturalHeight,i=H-n[1];e.drawImage(o,n[0]-a/2,i-r/2,a,r)}})}function drawLabels(e,t){e.textAlign="center",e.textBaseline="top",e.font="bold 42px Inter, sans-serif",t.forEach(function(t){var n=t.get("name");if(n){var o=t.getGeometry().getCoordinates(),a=o[0],r=H-o[1],i=0;t._pdfIcon&&(i=1.08*t._pdfIcon.naturalHeight);var c=r+i/2+10;e.strokeStyle="rgba(0,0,0,0.7)",e.lineWidth=4,e.lineJoin="round",e.strokeText(n.trim(),a,c),e.fillStyle="#ffffff",e.fillText(n.trim(),a,c)}})}async function exportMapPDF(e){e=e||{icons:!0,labels:!0};var t=document.getElementById("export-pdf-btn");t.textContent="...",t.disabled=!0;try{var n=document.createElement("canvas");n.width=W,n.height=H;var o=n.getContext("2d");await drawTiles(o);var a=vectorSource.getFeatures();e.icons&&(await loadFeatureIcons(a),drawIcons(o,a)),e.labels&&drawLabels(o,a);var r=window.jspdf.jsPDF,i=n.toDataURL("image/png"),c=W/96*25.4,d=H/96*25.4,s=new r({orientation:c>d?"landscape":"portrait",unit:"mm",format:[c,d]});s.addImage(i,"PNG",0,0,c,d),s.save("ravnina-map.pdf")}catch(e){console.error("Ошибка экспорта PDF:",e)}finally{t.textContent="PDF",t.disabled=!1}}document.addEventListener("DOMContentLoaded",function(){var e=document.getElementById("export-pdf-group"),t=document.getElementById("export-pdf-btn"),n=document.getElementById("export-pdf-panel"),o=document.getElementById("export-pdf-download"),a=n?n.querySelectorAll(".export-toggle"):[];t&&n&&(t.addEventListener("click",function(t){t.stopPropagation(),e.classList.toggle("expanded")}),a.forEach(function(e){e.addEventListener("click",function(t){t.stopPropagation(),e.classList.toggle("active")})}),o&&o.addEventListener("click",function(t){t.stopPropagation();var n={icons:!1,labels:!1};a.forEach(function(e){var t=e.dataset.opt;"icons"===t&&(n.icons=e.classList.contains("active")),"labels"===t&&(n.labels=e.classList.contains("active"))}),e.classList.remove("expanded"),exportMapPDF(n)}),document.addEventListener("click",function(){e.classList.remove("expanded")}),n.addEventListener("click",function(e){e.stopPropagation()}))});

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.