GPS Lat & Long returning wrong values

markh2011

Member
Licensed User
Longtime User
Can anybody please explain why the gps lat & long are different on google maps different from the gps lat and long when using the Location1.ConvertToMinutes(Location1.Latitude ) method.
I am in Australia and when i use google maps my lat = 37.57xxx long= 144.75xxx but when i use the gps code i get lat = 37.34xxx & long = 144.45xxx
 
Last edited:
Looks like one is decimal degrees and the other is degrees.minutes.

There are 60 minutes in a degree so .57 of a deg = 34 minutes and .75 of a degree is 45 minutes.

Bluejay
 
Upvote 0
Just looking at this now, from a great file called GPSLog posted here by a user

Here are 3 layouts he/she used


LatDatLbl.Text = NumberFormat2(Location1.Latitude,0,6,6,False)
LonDatLbl.Text = NumberFormat2(Location1.Longitude,0,6,6,False)

LatDatLbl.Text = Location1.ConvertToMinutes(Location1.Latitude)
LonDatLbl.Text = Location1.ConvertToMinutes(Location1.Longitude)

LatDatLbl.Text = Location1.ConvertToSeconds(Location1.Latitude)
LonDatLbl.Text = Location1.ConvertToSeconds(Location1.Longitude)
 
Upvote 0
Thanks for the info & resolving the issue.
I am having a bit of difficulty understanding what the NumberFormat2(Location1.Latitude,0,6,6,False) did to fix it.
Being a real newbie to b4a I really appreciate the help.
 
Last edited:
Upvote 0
Location1.Latitude returns a number, so its must be decimal degrees.

Location1.ConvertToMinutes(Location1.Latitude) just converts this number into a string with a special formatting.

NumberFormat2(Location1.Latitude,0,6,6,False) is formatting this number into a string showing the number with 6 decimal places for display purposes.

LatDatLbl.Text = Location1.Latitude would also work if you don't care how many decimal places are displayed since Basic4Android does implicit type conversion (in this case it would be from number to string).

bluejay
 
Upvote 0
LatDatLbl.Text = Location1.Latitude would also work if you don't care how many decimal places are displayed since Basic4Android does implicit type conversion (in this case it would be from number to string).

bluejay

But watch that allowing B4A to do the Double to String conversion may result in many decimal places in the String.

Lots of decimal places can soon overflow any label (or View) that you're displaying the coordinate in.

Martin.
 
Upvote 0

Similar Threads

Back
Top