Utilizzare una DrawingArea con gb.map anziché una MapView

Da Gambas-it.org - Wikipedia.
Versione del 31 mar 2015 alle 11:37 di Vuott (Discussione | contributi) (Creata pagina con 'Mostreremo di seguito un semplice codice esemplificativo, nel quale si farà uso di una ''DrawingArea'' anziché ddell'oggetto ''MapView'' per mostrare la mappa di "''openstre...')

(diff) ← Versione meno recente | Versione attuale (diff) | Versione più recente → (diff)

Mostreremo di seguito un semplice codice esemplificativo, nel quale si farà uso di una DrawingArea anziché ddell'oggetto MapView per mostrare la mappa di "openstreetmap".

Bisognerà porre sul Form una DrawingArea, uno Slider ed un ValueBox per lo zoom. Si dovrà, inoltre, attivare il componente gb.map.

Private hMap As New Map    
Private x As Short  
Private y As Short  
  
  
Public Sub _New()    
  
 With hMap.AddTile("OpenStreet", "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png")      
   .Copyright = "OpenStreetMap contributors"      
 End With    
    
End
  
  
Public Sub Form_Open()    
 
 With Me  
   .W = 700  
   .H = 650  
   .Center  
 End With  
 
 With ValueBox1  
   .X = Me.W - 64  
   .Y = 30  
 End With  
  
 With Slider1      
   .X = Me.W - 60  
   .Y = ValueBox1.Y + ValueBox1.H + 10  
   .Value = 3     
   .MaxValue = 18  
   .MinValue = 1  
 End With    
  
 hMap.Zoom = Slider1.Value  
  
 With DrawingArea1  
   .W = 600  
   .H = 600  
 End With  
  
 With hMap    
   .Center.Lat = 41  
   .Center.Lon = 13  
 End With   
   
 DrawingArea1.Refresh()   
   
End    
  
  
Public Sub DrawingArea1_Draw()      
    
 With hMap 
   .Width = Draw.Width      
   .Height = Draw.Height      
   .Draw()    
 End With    
   
 DrawingArea1.Refresh()    
  
End    
  
  
Public Sub Slider1_Change()      
   
 hMap.Zoom = Slider1.Value      
 ValueBox1.Value = Slider1.Value      
 hMap.Refresh       
   
End  
 
 
Public Sub DrawingArea1_MouseMove()  
 
 With hMap  
   .Center.Lat = .Center.Lat - ((y - Mouse.Y) / (10 ^ Round(Slider1.Value / 3)))  
   .Center.Lon = .Center.Lon + ((x - Mouse.X) / (10 ^ Round(Slider1.Value / 3)))  
 End With    
 
 x = Mouse.X  
 y = Mouse.Y  
 
 DrawingArea1.Refresh()    
  
End  
 
 
Public Sub DrawingArea1_MouseDown()  
 
 x = Mouse.X  
 y = Mouse.Y  
  
End