Ottenere un file pdf dalla mappa mostrata da una MapView

Da Gambas-it.org - Wikipedia.

Per ottenere la stampa su un file PDF della mappa mostrata dalla MapView, è possibile utilizzare le risorse della Classe "Printer". [Nota 1]

Mostriamo un esempio pratico:

Private MapView1 As MapView
Private Printer1 As Printer
Private mp As New MapPoint(41.8902142, 12.4900422)

Public Sub Form_Open()

 With Me
   .W = Screen.AvailableWidth
   .H = Screen.AvailableHeight
   .Arrangement = Arrange.Fill
 End With

 With MapView1 = New MapView(Me) As "MapView1"
' Imposta un "Raster Tiles Server" remoto:
   .Map.AddTile("opentopo", "https://a.tile.opentopomap.org/{z}/{x}/{y}.png")
   .Map.Zoom = 15
' Imposta il centro della mappa visualizzata specificandone preliminarmente le coordinate geografiche:
   .Map.Center = mp
 End With

 With Printer1 = New Printer As "Printer1"
   .Resolution = Desktop.Resolution
   .Paper = .A4
   .Orientation = .Landscape
' Stampa su un file .pdf (crea un file .pdf):
   .OutputFile = "/tmp/file.pdf"
 End With

End

Public Sub MapView1_MouseUp()

' Se si clicca con il tasto destro del mouse sulla mappa, si avvia la stampa su un file .pdf:
 If Mouse.Right Then Printer1.Print

End

Public Sub Printer1_Draw() ' Esegue la stampa su un file .pdf della mappa mostrata:

 With MapView1.Map
   .Width = MapView1.W
   .Height = MapView1.H
   .Draw()
 End With

End


Note

[1] Riguardo alla creazione di un file pdf con la Classe "Printer", vedere anche: Stampare in un file .pdf