#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: true
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim TileSource As String
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim MapView1 As MapView
Dim MapCenter As GeoPoint
Dim TouchEventsOverlay1 As TouchEventsOverlay
' create the SimpleLocationOverlay
Dim SimpleLocationOverlay1 As SimpleLocationOverlay
Dim BoundaryBox As BoundingBox
Dim coords As String
Dim Nord(4) As String
Dim NordValues(4) As Double
Dim Timer1 As Timer 'Used to create a delay
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
' pass an EventName when initializing the MapView
' MapView has two events: CenterChanged and ZoomChanged
Timer1.Initialize( "Timer1",10)
MapView1.Initialize("MapView1")
Activity.AddView(MapView1, 0, 0, 100%x, 100%y)
MapView1.SetMultiTouchEnabled(True)
MapView1.SetZoomEnabled(True)
MapCenter.Initialize(47.3763900,15.0911300) 'Leoben as center
TileSource="MapquestOSM"
MapView1.Zoom=15
MapView1.SetCenter(47.3763900,15.0911300)
MapView1.SetTileSource(TileSource)
Activity.Title="OSMDroid ["&MapView1.Zoom&"]"
'Log("MapView1.Center: " & MapView1.GetCenter)
'initialize the SimpleLocationOverlay and add it to the MapView
SimpleLocationOverlay1.Initialize(MapView1)
MapView1.AddOverlay(SimpleLocationOverlay1)
'set the SimpleLocationOverlay to display it's icon at the map center
SimpleLocationOverlay1.SetMyLocation3(MapView1.GetCenter)
TouchEventsOverlay1.Initialize("TouchEventsOverlay1")
MapView1.AddOverlay(TouchEventsOverlay1)
Log("Before Timer1: " & MapView1.GetBoundingBox2(MapView1.Width, MapView1.Height))
'Log(MapView1.GetBoundingBox)
Timer1.Enabled=True 'Wait for a short period
End Sub
Sub GetCoordinates
Log("After Timer1: " & MapView1.GetBoundingBox2(MapView1.Width, MapView1.Height))
coords=MapView1.GetBoundingBox2(MapView1.Width, MapView1.Height)
coords=coords.Replace("(BoundingBoxE6) N:","")
coords=coords.Replace("E:","")
coords=coords.Replace("S:","")
coords=coords.Replace("W:","")
coords=coords.Replace("; ",",")
Nord=Regex.Split(",",coords)
For i=0 To Nord.Length-1
NordValues(i)=Nord(i)
NordValues(i)=NordValues(i)/1000000
'Log(NordValues(i))
Next
End Sub
Sub Timer1_Tick
Log("Timer finished")
Timer1.Enabled=False
GetCoordinates
End Sub
' listen for the MapView ZoomChanged event
Sub MapView1_ZoomChanged
Log("MapView1_ZoomChanged ZoomLevel="&MapView1.Zoom)
Activity.Title="OSMDroid ["&MapView1.Zoom&"]"
Log("ZoomCHangedEvent: " & MapView1.GetBoundingBox2(MapView1.Width, MapView1.Height))
End Sub
Sub TouchEventsOverlay1_Click(GeoPoint1 As GeoPoint)
Log("Click")
Log(GeoPoint1.Latitude & "," & GeoPoint1.Longitude)
Log(MapView1.GetBoundingBox2(MapView1.Width, MapView1.Height))
End Sub
Sub TouchEventsOverlay1_LongClick(GeoPoint1 As GeoPoint)
Log("LongClick")
End Sub