#Region Project Attributes
#ApplicationLabel: pci
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: True
'#AdditionalRes:H:\My Backup\ADT\extras\google\google_play_services\libproject\google-play-services_lib\res, com.google.android.gms
#AdditionalRes:H:\My Backup\ADT\extras\google\google-play-services\libproject\google-play-services_lib\res,com.google.android,gms
#AdditionalJar: com.google.android.gms:play-services-maps
#End Region
#Region Activity Attributes
#FullScreen: False
#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.
'map key = 'AIzaSyArj1Jvj-VfaGZLDg3TRE3yrdbfEI6AlZ8'
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 spa As Spatialite_Database
Dim spconstants As Spatialite_Constants
Private ListView1 As ListView
Private lbllat As Label
Private lbllon As Label
Private lblSatellites As Label
Private WKBReader1 As JTS_WKBReader
Private Panel1 As Panel
Private Label_Details As Label
Private Button_close As Button
Private Map_panel As Panel
Dim gmap As GoogleMap
Dim mFragment As MapFragment
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")
' Map_panel.Initialize("")
'Activity.AddView(MapPanel, 0, 0, 100%x, 100%y)
If mFragment.IsGooglePlayServicesAvailable = False Then
ToastMessageShow("Google Play services not available.", True)
' Else
' mFragment.Initialize("Map", Map_panel)
End If
If FirstTime Then
spa.Initialize
If File.ExternalWritable=True Then
'If File.Exists(File.DirRootExternal, "veg1.db") = False Then
File.Copy(File.DirAssets, "mm.sqlite", File.DirRootExternal, "mm.sqlite")
'End If
spa.Open(File.DirRootExternal, "mm.sqlite", spconstants.SQLITE_OPEN_READWRITE)
Else
'If File.Exists(File.DirInternal, "veg1.db") = False Then
File.Copy(File.DirAssets, "mm.sqlite", File.DirInternal, "mm.sqlite")
'End If
'sql1.Initialize(File.DirInternal, "veg1.db", True)
spa.Open(File.DirInternal, "mm.sqlite", spconstants.SQLITE_OPEN_READONLY)
End If
populate
End If
'spa.Open(File.DirAssets,"mm.sqlite",spconstants.SQLITE_OPEN_READONLY)
End Sub
Sub MapFragment1_Ready
gmap = mFragment.GetMap
Dim m1 As Marker = gmap.AddMarker(10, 30, "test")
m1.Snippet = "This is the snippet"
End Sub
'Sub Map_Ready
' Log("map ready")
' gmap = mFragment.GetMap
' If gmap.IsInitialized = False Then
' ToastMessageShow("Error initializing map.", True)
' Else
' gmap.AddMarker(36, 15, "Hello!!!")
' Dim cp As CameraPosition
' cp.Initialize(36, 15, gmap.CameraPosition.Zoom)
' ' gmap.AnimateCamera(cp)
' End If
'End Sub
Sub populate
'Dim sqlstring As String
' sqlstring= "SELECT
'Dim CountryNames As List
Dim SpatialiteStatement As Spatialite_Stmt
'CountryNames.Initialize
SpatialiteStatement=spa.Prepare("SELECT ROAD_NAME, PKUID FROM DRRP_Roads where PCI is Null ORDER BY ROAD_NAME ASC")
Do While SpatialiteStatement.Step
ListView1.AddTwoLines2(SpatialiteStatement.ColumnString(0),SpatialiteStatement.ColumnInt(1),SpatialiteStatement.ColumnInt(1))
Loop
SpatialiteStatement.Close
' Return CountryNames
End Sub
Sub Activity_Resume
If Starter.GPS1.GPSEnabled = False Then
ToastMessageShow("Please enable the GPS device.", True)
StartActivity(Starter.GPS1.LocationSettingsIntent) 'Will open the relevant settings screen.
Else
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
End If
End Sub
Sub Activity_Pause (UserClosed As Boolean)
CallSub(Starter, "StopGPS")
End Sub
Sub Activity_PermissionResult (Permission As String, Result As Boolean)
If Permission = Starter.rp.PERMISSION_ACCESS_FINE_LOCATION Then
If Result Then CallSub(Starter, "StartGPS")
End If
End Sub
Public Sub GpsStatus (Satellites As List)
Dim sb As StringBuilder
sb.Initialize
sb.Append("Satellites:").Append(CRLF)
For i = 0 To Satellites.Size - 1
Dim Satellite As GPSSatellite = Satellites.Get(i)
sb.Append(CRLF).Append(Satellite.Prn).Append($" $1.2{Satellite.Snr}"$).Append(" ").Append(Satellite.UsedInFix)
sb.Append(" ").Append($" $1.2{Satellite.Azimuth}"$).Append($" $1.2{Satellite.Elevation}"$)
Next
lblSatellites.Text = sb.ToString
End Sub
Public Sub LocationChanged(Location1 As Location)
lbllat.Text = "Lat = " & Location1.ConvertToMinutes(Location1.Latitude)
lbllon.Text = "Lon = " & Location1.ConvertToMinutes(Location1.Longitude)
'lblSpeed.Text = $"Speed = $1.2{Location1.Speed} m/s "$
End Sub
Public Sub Listview1_ItemClick (Position As Int, Value As Object)
Dim id As Int=Value
Dim txt As String = ""
Dim SpatialiteStatement As Spatialite_Stmt
'CountryNames.Initialize
SpatialiteStatement=spa.Prepare("SELECT ROAD_NAME, ROAD_ID,RD_LENGTH, ASTEXT(Geometry) FROM DRRP_Roads where PKUID =" & id)
Do While SpatialiteStatement.Step
txt=SpatialiteStatement.ColumnString(0) & CRLF
txt =txt & "Road ID:" & SpatialiteStatement.Columnint(1) & CRLF
txt =txt & "Length(Km):" & SpatialiteStatement.ColumnDouble(2) & CRLF
txt =txt & "Latlon:" & SpatialiteStatement.ColumnString(3) & CRLF
Label_Details.Text=txt
Loop
SpatialiteStatement.Close
Panel1.Visible=True
' Dim pl As Polyline = gmap.AddPolyline
' Dim l1, l2 As LatLng
' l1.Initialize(30, 30)
' l2.Initialize(40, 30)
' Dim points As List
' points.Initialize
' points.Add(l1)
' points.Add(l2)
' pl.points = points
End Sub
Sub Button_close_Click
Panel1.Visible=False
End Sub