Android Question GPS routes strange. Maybe android.permission.ACCESS_FINE_LOCATION needed?

Facilauto Juan

Member
Licensed User
Longtime User
Hello there!

I'm recording latitude-longitude points in order to show them in a google map. But I'm having strange routes drawn in the map. Like I was inside the buildings instead in the road.

How could I get more accurate readings? Maybe using android.permission.ACCESS_FINE_LOCATION? If so... how should I write it down in the manifest editor?

Thanks for the answers and your time.
 

jsanchezc

Member
Licensed User
Longtime User
Hello there!

I'm recording latitude-longitude points in order to show them in a google map. But I'm having strange routes drawn in the map. Like I was inside the buildings instead in the road.

How could I get more accurate readings? Maybe using android.permission.ACCESS_FINE_LOCATION? If so... how should I write it down in the manifest editor?

Thanks for the answers and your time.

If you are saving data each minute or between more than 10 ...50 meters... then you
should load map drawing route instead polygon.

You have two options:
save data very often ... each 4 or 6 meters and draw polygon between points... high battery cost
or save data not so often and draw route between points. less battery cost.

This sample is based on make url with points and call maps.google as web page
It has a limit of max 25 points so if you have more than 25 points you can
call to view a range (0-24 ....25 to 49 ....)
https://maps.google.es/maps?output=...333 to: +41.0031,02.00444+to:+41.0041,02.0555

B4X:
Sub VerMapaRuta(Inicio As Int)
  'Ver el mapa de la ruta.....
  Dim WbString As String =""
  WbString="http://maps.google.es/maps?output=embed&saddr=" 
   Dim SQLString As String =""
  Dim Dr As Cursor
   Dim Numeroregistros As String ="0"
   '--------------------------------
   SQLString="Select "
   SQLString=SQLString & "lat "
   SQLString=SQLString & ",lon "
  SQLString=SQLString & " from roadbooklineas "
   SQLString=SQLString & " where idruta='" & IdRutaEditar.trim & "'"
   SQLString=SQLString & " order by paso "
  If SQL1.IsInitialized=False Then
  SQL1.Initialize ( File.DirDefaultExternal & "/data"  ,"rdbk.sqlite",False)
  End If
  Dr=SQL1.ExecQuery(SQLString)
  Numeroregistros=Dr.RowCount
   If Numeroregistros >0 Then
    If Numeroregistros > Inicio + 25 Then
    Numeroregistros=Inicio + 25
    End If
    'datos del paso
     For I=Inicio To Numeroregistros-1
      Dr.Position =I   
      If I>Inicio AND Dr.GetString("lat").Trim <>"" AND Dr.GetString("lon").Trim<>"" Then
      WbString=WbString & " to: "
      End If
      If Dr.GetString("lat").Trim <>"" AND Dr.GetString("lon").Trim<>"" Then
      WbString=WbString & Dr.GetString("lat") & "," & Dr.GetString("lon") & " "
      End If
     Next
  Dr.Close
'   SQL1.Close
   Log (WbString)
   webvisor.UrlToShow =WbString
   StartActivity(webvisor)   
  Else
    Dr.Close
   'SQL1.Close

   End If
     
End Sub
 
Upvote 0

Facilauto Juan

Member
Licensed User
Longtime User
That solution won't help me, but thanks. I'm recording the route every second. I don't mind if its too battery consuming, because it's only for a limited period of time. But I do need the route to be accurate. If I'm on the road, the route shouldn't be showing me inside the buildings.
 
Upvote 0

jsanchezc

Member
Licensed User
Longtime User
If you take point each few seconds and use GPS, you will get accuracy between 4-8 meters,
so your points sould not be at buildings...
B4X:
Sub Process_Globals
   Dim awake As PhoneWakeState
   Dim EstadoActivo As Boolean=False
   Dim GPSx As GPS
   ../..
End Sub

Sub Globals
   Dim LatActual As String=""
   Dim LonActual As String =""
   
   Dim VelocidadActual As String=""
   Dim PrecisionActual As String=""
   Dim LocationActual As Location 
   ../..
End Sub 



   
Sub Activity_Resume

  ../..
  GPSx.Initialize ("Gpsx")
  If GPSx.GPSEnabled =False Then
   
  Else
   GPSx.Start (0  ,  0 ) ' continuous..... GPSx.Start (0  ,  4 ) 'also works ok   
  End If
  If EstadoActivo=False Then
      awake.KeepAlive(True) 'avoid device sleep
   EstadoActivo=True
 End If
 ../..
End Sub


Sub Activity_Pause (UserClosed As Boolean)
   GPSx.Stop 
   If EstadoActivo=True Then
      awake.KeepAlive(False)
      EstadoActivo=False
   End If
   ../..
End Sub

Sub GPSx_LocationChanged (Location1 As Location)
   If Location1.Accuracy < 128 Then 'discard low accuracy points
       LatActual=Location1.Latitude
       LonActual = Location1.Longitude
       LocationActual=Location1
       VelocidadActual=Location1.Speed
       PrecisionActual=Location1.Accuracy
     End If
End Sub
 
Upvote 0
Top