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à ovviamente attivare il Componente gb.map . [Nota 1]

Private DrawingArea1 As DrawingArea
Private hMap As New Map    
Private x As Integer
Private y As Integer
Private mp As MapPoint(35.864483, 12.867534)
Private pt As New Point
 
 
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": "900"]).SubDomains = ["0", "1", "2"]
   .Center = mp
 End With
 With Me  
   .W = Desktop.W
   .H = Desktop.H
   .Arrangement = Arrange.Fill
 End With
 With DrawingArea1 = New DrawingArea(Me) As "DrawingArea1"
   .X = 0
   .Y = 0
 End With
 
End
 
 
Public Sub Form_Open()
 
 hMap.Zoom = 6  
 Me.Text = "Zoom: " & CStr(6)
  
End
 
 
Public Sub DrawingArea1_Draw()
 
 With hMap
   .Width = Paint.W
   .Height = Paint.H
   .Center = mp
   .Draw()
 End With
 
 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) / ((hMap.Zoom * 10) / (hMap.Zoom - c[hMap.Zoom - 1]))
   .Center.Lon += ((mx ^ 0) * mx) / ((hMap.Zoom * 10) / (hMap.Zoom - c[hMap.Zoom - 1]))
 End With
 
 x = Mouse.X  
 y = Mouse.Y  
 
End
 
 
Public Sub DrawingArea1_MouseDown()  
 
 pt = Point(Mouse.X, Mouse.Y)
 
 Me.Text = "Lat. " & Format(hMap.PixelToMapPointRel(pt).Lat, "0.000000") & 
           "   Lon. " & Format(hMap.PixelToMapPointRel(pt).Lon, "0.000000") &
           "  -  Zoom: " & CStr(hMap.Zoom)
 
 x = pt.X  
 y = pt.Y
 
End
 

Public Sub DrawingArea1_MouseWheel()
 pt = Point(Mouse.X, Mouse.Y)
 mp.Lat = hMap.PixelToMapPointRel(pt).Lat
 mp.Lon = hMap.PixelToMapPointRel(pt).Lon
 
 If Mouse.Delta > 0 Then 
   hMap.Zoom += 1
 Else 
   hMap.Zoom -= 1
 Endif
 Me.Text = "Zoom: " & CStr(hMap.Zoom)
 
End



Note

[1] Qualora la mappa non appaia, verificare la versione GoogleMap, ed eventualmente modificarla in questo punto: ["version": "900"]
Al riguardo vedere: Conoscere la versione più recente di Google Maps satellite