Add new functions to MapPoint class to get MapPoint from text representation and get string from mappoint.
[GB.MAP] * NEW: Add new functions to MapPoint class to get MapPoint from text representation and get string from mappoint. * BUG: Map, do not allow to set a null MapPoint to the center property.
This commit is contained in:
parent
b350f4fe55
commit
f446879826
6 changed files with 32 additions and 14 deletions
comp/src/gb.map
|
@ -1,6 +1,6 @@
|
|||
[Component]
|
||||
Key=gb.map
|
||||
Version=3.17.90
|
||||
Version=3.18.90
|
||||
State=1
|
||||
Authors=Fabien Bodard
|
||||
Needs=Form,ImageIO
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# Gambas Project File 3.0
|
||||
Title=gb.map
|
||||
Startup=Form6
|
||||
Startup=Form7
|
||||
Icon=.hidden/control/mapview.png
|
||||
Version=3.17.90
|
||||
Version=3.18.90
|
||||
VersionFile=1
|
||||
Component=gb.image
|
||||
Component=gb.gui
|
||||
|
|
|
@ -170,7 +170,8 @@ End
|
|||
|
||||
Private Sub Center_Write(Value As MapPoint)
|
||||
|
||||
'Print Value.Lat, Value.Lon
|
||||
'Can't be null
|
||||
If IsNull(Value) Then Return
|
||||
$mpCenter = Value
|
||||
SetBoxes
|
||||
|
||||
|
|
|
@ -1,9 +1 @@
|
|||
' Gambas class file
|
||||
|
||||
|
||||
Public Sub Form_Open()
|
||||
|
||||
MapView1.Map.AddTile("OpenStreetMap", "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", Null, "OpenStreetMap1").Copyright = "© OpenStreetMap contributors"
|
||||
Dim hLayer As New _BalloonLayer
|
||||
MapView.Map._AddMapLayer("test", hLayer)
|
||||
End
|
||||
|
|
|
@ -209,3 +209,27 @@ Static Public Function GetCenter(hPoints As MapPoint[]) As MapPoint
|
|||
Catch
|
||||
|
||||
End
|
||||
|
||||
''Get string representation in decimal of a mappoint.
|
||||
Static Public Sub ToString(hMp As MapPoint) As String
|
||||
|
||||
Return CStr(hMp.Lat) & ", " & CStr(hMp.Lon)
|
||||
|
||||
End
|
||||
|
||||
|
||||
''Get a MapPoint from a string representation in decimal.
|
||||
Static Public Sub FromString(sMp As String) As MapPoint
|
||||
|
||||
Dim a As String[] = Scan(sMp, "*,*")
|
||||
|
||||
'if not able to get the values then return null
|
||||
If IsNull(a) Then Return
|
||||
|
||||
'if not 2 value then return null
|
||||
If a.Count < 2 Then Return
|
||||
|
||||
'Try to convert str to float values
|
||||
Try Return MapPoint(CFloat(a[0]), CFloat(a[1]))
|
||||
|
||||
End
|
||||
|
|
|
@ -49,7 +49,7 @@ Public Sub _Load()
|
|||
|
||||
Dim hMap As Map = Me._GetMap()
|
||||
Dim pt1, pt2 As Point
|
||||
|
||||
|
||||
$aInView.Clear
|
||||
For i As Integer = 0 To $aShapes.Max
|
||||
If Not ($aShapes[i].Type = _Point) Then
|
||||
|
@ -80,7 +80,7 @@ End
|
|||
Public Sub AddPoint(Key As String, Points As MapPoint, Optional {Color} As Integer, Optional Icon As Image) As _MapShapeItem
|
||||
|
||||
If $aShapeNames.Exist(Key) Then Error.Raise("This key already exist")
|
||||
|
||||
If IsNull(Points) Then Error.Raise("Points is null")
|
||||
Dim hItem As New _MapShapeItem(Key) As "Item"
|
||||
|
||||
If Not IsMissing(Icon) Then hItem.Image = Icon
|
||||
|
@ -207,6 +207,7 @@ Public Sub Draw()
|
|||
Dim iAlpha As Integer
|
||||
|
||||
If $aShapes.Count = 0 Then Return
|
||||
|
||||
For i As Integer = 0 To $aInView.Max
|
||||
|
||||
'TODO: Check opacity
|
||||
|
|
Loading…
Reference in a new issue