What is the proper way to print custom Overlays to PDF?
I have a Google map, several Shapefiles and inMemoryMarkerOvelay on a page.
I want to print it to PDF. I am unable to use your sample code as it uses static Ovelray.
I tried to iterate through CustomOverlays and all layers but get error that GoogleMap is not a LayerOverlay.
Help?
Here is the code i am using:
Protected Sub btnToPdf_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim document As New PdfDocument()
Dim page As PdfPage = document.AddPage()
If rdlOptions.SelectedItem.Text = "Landscape" Then
page.Orientation = PageOrientation.Landscape
End If
Dim pdfGeoCanvas As New PdfGeoCanvas()
' This allows you to control the area in which you want the
' map to draw in. Leaving this commented out uses the whole page
'pdfGeoCanvas.DrawingArea = new Rectangle(200, 50, 400, 400);
Dim labelsInLayers As New Collection(Of SimpleCandidate)()
For Each overlay As Overlay In Map1.CustomOverlays
Dim currentOverlay As LayerOverlay = overlay
For Each layer As Layer In currentOverlay.Layers
Dim printExtent As RectangleShape = ExtentHelper.GetDrawingExtent(Map1.CurrentExtent, CSng(Map1.WidthInPixels), CSng(Map1.HeightInPixels))
pdfGeoCanvas.BeginDrawing(page, printExtent, GeographyUnit.DecimalDegree)
layer.Open()
layer.Draw(pdfGeoCanvas, labelsInLayers)
layer.Close()
pdfGeoCanvas.EndDrawing()
Next
Next
Dim filename As String = Directory.GetCurrentDirectory() & "\MapSuite PDF Map.pdf"
document.Save(filename)
OpenPdfFile(filename)
End Sub