Use the method PaintToCanvas of the MapView's drawing engine in order to paint the currently visible map to a bitmap. Then apply standard techniques to stretch-draw this bitmap to the printer's Canvas:
uses
... printers, OSPrinters;
procedure TMainForm.Button3Click(Sender: TObject);
const
LEFT_MARGIN = 10.0; // mm
TOP_MARGIN = 10.0; // mm
var
bmp: TBitmap;
PrintedRect: TRect;
begin
if PrintDialog1.Execute then
begin
Printer.Orientation := poLandscape;
Printer.BeginDoc;
try
// Catch the displayed map as a bitmap.
bmp := TBitmap.Create;
try
bmp.SetSize(MapView.Width, MapView.Height);
MapView.DrawingEngine.PaintToCanvas(bmp.Canvas);
// Calculate output rectangle for image. It must be scaled by the
// ratio of printer-to-screen pixels per inch.
PrintedRect := Rect(0, 0,
MapView.Width * Printer.XDPI div ScreenInfo.PixelsPerInchX,
MapView.Height * Printer.YDPI div ScreenInfo.PixelsPerInchY
);
// Move output rectangle to desired position, here: in the top/left corner
OffsetRect(PrintedRect,
round(Printer.XDPI/25.4 * LEFT_MARGIN),
round(Printer.YDPI/25.4 * TOP_MARGIN)
);
// Stretch-draw the map image to the output rectangle on the printer.
Printer.Canvas.StretchDraw(PrintedRect, bmp);
finally
bmp.Free;
end;
finally
Printer.EndDoc;
end;
end;
end;
I extended the "fulldemo" of the LazMapViewer package by a bit more advanced code in which the map is scaled such that if fills the width (height) of the printed page (with margins)