Utilizzare una DrawingArea con gb.map anziché una MapView

Da Gambas-it.org - Wikipedia.

Mostreremo di seguito un semplice codice esemplificativo, nel quale si farà uso di una DrawingArea anziché dell'oggetto MapView.

Bisognerà porre sul Form una DrawingArea, uno Slider, un LCDLabel per lo zoom e due RadioButton per scegliere il sistema di riferimento delle coordinate, altresì attivare i Componenti gb.map e gb.qt5 e gb.qt5.ext . [Nota 1]

Private hMap As New Map    
Private x As Integer
Private y As Integer
Private mp As MapPoint
Private pt As New Point
Private coo As Boolean
 
 
Public Sub _New()    
 
 With hMap
   .AddTile("GoogleMaps", "https://khms{s}.google.it/kh/v={version}&src=app&x={x}&y={y}&z={z}&s=Galile", ["version": "860"]).SubDomains = ["0", "1", "2"]
   mp = MapPoint(34.976001513175, 13.3154296875)
   .Center = mp
 End With
 With Me  
   .W = Desktop.W
   .H = Desktop.H  
 End With
 With DrawingArea1  
   .X = Me.W * 0.007
   .Y = Me.H * 0.01
   .W = Me.W * 0.96
   .H = Me.H * 0.95
 End With
 With LCDLabel1
   .X = Me.W * 0.967
   .Y = Me.H * 0.04
   .W = Me.W * 0.02
   .H = Me.H * 0.02
   .Alignment = Align.Right
   .Foreground = Color.Red
   .Font.Size = 18
   .Font.Bold = True
 End With
 With RadioButton1
   .X = Me.W * 0.97
   .Y = Me.H * 0.2
   .W = Me.W * 0.04
   .H = Me.H * 0.02
   .Text = "sess."
   .Value = True
 End With
 With RadioButton2
   .X = Me.W * 0.97
   .Y = RadioButton1.Y + RadioButton1.H
   .W = Me.W * 0.04
   .H = Me.H * 0.02
   .Text = "decm."
 End With
 
End
 
 
Public Sub Form_Open()
 
 With Slider1
   .X = Me.W * 0.975
   .Y = Me.H * 0.07
   .Value = 6
   .MaxValue = 18
   .MinValue = 6
 End With    
 
 hMap.Zoom = Slider1.Value  
 
 DrawingArea1.Refresh()
  
End
 
 
Public Sub DrawingArea1_Draw()
 
 Dim lat, lon As String
 Dim sla, slo As String
 
 With hMap
   .Width = Paint.W
   .Height = Paint.H
   .Draw()
 End With
 
 lat = hMap.PixelToMapPointRel(pt).Lat
 lon = hMap.PixelToMapPointRel(pt).Lon
 sla = CStr(lat)
 slo = CStr(lon)
 
 If coo Then
   With Paint
     .Brush = Paint.Color(Color.Red)
     .Font.Size = 16
     .Ellipse(x - 1, y - 1, 4, 4)
     .Font.Size = 8
     If RadioButton1.Value Then
       sla = Geo.DecToSex(lat, 1)
       slo = Geo.DecToSex(lon, 2)
     Endif
     .Text(" " & sla & "\n " & slo, x, y, 120, 20)
     .Fill
     .End
   End With
 Endif
 
 DrawingArea1.Refresh()
 
End
 
 
Public Sub DrawingArea1_MouseMove()  
 
 Dim c As New Single[18]
 Dim mx, my As Short
 
 c = [0, 0, 0, 0, 0, 5, 6.4, 7.6, 8.8, 9.9, 10.9, 11.9, 12.94, 13.96, 14.98, 15.98, 16.99, 17.994]
 
 mx = (x - Mouse.X)
 my = (y - Mouse.Y)
 
 With hMap  
   .Center.Lat -= ((my ^ 0) * my) / ((Slider1.Value * 10) / (Slider1.Value - c[Slider1.Value - 1]))
   .Center.Lon += ((mx ^ 0) * mx) / ((Slider1.Value * 10) / (Slider1.Value - c[Slider1.Value - 1]))
 End With
 
 x = Mouse.X  
 y = Mouse.Y  
 
End
 
 
Public Sub DrawingArea1_MouseDown()  
 
 pt = pt(Mouse.X, Mouse.Y)
 x = Mouse.X  
 y = Mouse.Y  
 coo = False
  
End
 

Public Sub DrawingArea1_MouseUp()
 
' Se si clicca con il tasto destro del mouse, vengono stampate sulla mappa
' le coordinate geografiche del punto, ove si è cliccato:
 
 If Mouse.Right Then
   pt = pt(Mouse.X, Mouse.Y)
   mp = MapPoint(hMap.PixelToMapPointRel(pt).Lat, hMap.PixelToMapPointRel(pt).Lon)
   coo = True
 Endif
  
End


Public Sub Slider1_Change()
  
 hMap.Zoom = Slider1.Value
 LCDLabel1.Value = Slider1.Value
 coo = False
 
End




Note

[1] Qualora la mappa non appaia, verificare la versione GoogleMap, ed eventualmente modificarla in questo punto: ["version": "860"]
Al riguardo vedere: https://www.gisenglish.com/2018/06/download-sas-planet-nightly-all.html