:ciao:
' Gambas class file
Private hMap As New Map
Public Sub _New()
With hMap.AddTile("OpenStreet", "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png")
.Copyright = "OpenStreetMap contributors"
End With
End
Public Sub DrawingArea1_Draw()
hMap.Center.Lat = 45
hMap.Center.Lon = 9
'hMap.Zoom = 10
hMap.Width = Draw.Width
hMap.Height = Draw.Height
hMap.Draw()
DrawingArea1.Refresh()
End
Se hMap.Zoom è commentato la cartina è centrata nel punto voluto ovviamente senza Zoom, se tolgo il commento la cartina non viene disegnata!
:-\
......poniamo sul Form anche uno Slider ed un ValueBox1 per variare lo zoom e visualizzare il valore:
Private hMap As New Map
Public Sub _new()
hMap.AddTile("OpenStreet", "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png")
hMap!OpenStreet.Copyright = "© OpenStreetMap contributors"
hMap.AddShape("MyShape")
hMap!MyShape.AddPoint("alibaba", MapPoint(45.678, 9.120))
hMap.Center = hMap!MyShape!alibaba.Points
hMap.Zoom = 12
hMap.Refresh
End
Public Sub Form_Open()
With Slider1
.Value = 12
.MaxValue = 20
.MinValue = 1
End With
End
Public Sub DrawingArea1_Draw()
hMap.Width = Draw.Width
hMap.Height = Draw.Height
hMap.Draw()
DrawingArea1.Refresh()
End
Public Sub Slider1_Change()
hMap.Zoom = Slider1.Value
ValueBox1.Value = Slider1.Value
hMap.Refresh
End
... la mia soluzione perchè non funziona? -
Perché hai posto la proprietà dello zoom all'interno della sub-procedura di disegno della DrawingArea.
Il tuo codice, molto più semplice e breve del mio, così funziona:
Private hMap As New Map
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 Slider1
.Value = 12
.MaxValue = 20
.MinValue = 1
End With
hMap.Zoom = 12
End
Public Sub DrawingArea1_Draw()
With hMap
.Center.Lat = 45
.Center.Lon = 9
.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