getMessage())); } function generateMapForPDF($mapId, $basemaps, $layers, $centerLon, $centerLat, $zoom, $width, $height) { $config = getGeoServerConfig(); $proxyUrl = 'geoserver_proxy.php?map_id='$mapId; ob_start(); ?>
SetCreator('GeoLite'); $pdf->SetAuthor('GeoLite System'); $pdf->SetTitle('Map Export: ' . $map['title']); $pdf->SetSubject('Map Export'); // Set margins $pdf->SetMargins(15, 15, 15); $pdf->SetAutoPageBreak(TRUE, 15); // Add a page $pdf->AddPage(); // Set font $pdf->SetFont('helvetica', 'B', 16); $pdf->Cell(0, 10, 'Map Export: ' . $map['title'], 0, 1, 'C'); $pdf->SetFont('helvetica', '', 12); $pdf->Ln(5); // Map information $pdf->Cell(0, 8, 'Map Information:', 0, 1, 'L'); $pdf->SetFont('helvetica', '', 10); $pdf->Cell(0, 6, 'Center: ' . $centerLon . ', ' . $centerLat, 0, 1, 'L'); $pdf->Cell(0, 6, 'Zoom Level: ' . $zoom, 0, 1, 'L'); $pdf->Cell(0, 6, 'Export Date: ' . date('Y-m-d H:i:s'), 0, 1, 'L'); $pdf->Ln(5); $pdf->SetFont('helvetica', '', 12); $pdf->Cell(0, 8, 'Layers:', 0, 1, 'L'); $pdf->SetFont('helvetica', '', 10); foreach ($layers as $layer) { $layerName = explode(':', $layer)[1] ?? $layer; $pdf->Cell(0, 6, '• ' . $layerName, 0, 1, 'L'); } $pdf->Ln(10); $pdf->SetFont('helvetica', '', 10); $pdf->Cell(0, 6, 'Note: This is a text-based export. For visual map export,', 0, 1, 'C'); $pdf->Cell(0, 6, 'please use the browser\'s print function or take a screenshot.', 0, 1, 'C'); // Output PDF $pdf->Output('map_export.pdf', 'D'); } // Check if TCPDF is available, if not, create a simple HTML response if (!class_exists('TCPDF')) { // Fallback: create a simple HTML page that can be printed ob_start(); ?>Map Export -
Center: ,
Zoom Level:
Export Date:
Note: This is a text-based export. Use your browser's print function (Ctrl+P) to create a PDF.