Navigation application / (layar)

Tutorials that use the MapActivity. Many using GPS functionality.

Navigation application / (layar)

Postby Cycl0ps » Mon Apr 26, 2010 11:07 am

Hello,

Im trying to make an application like Layar, now im comming to the hardest part of the coding.
I want can get my GPS coordinates and can call the GPS coordinates of the locations I want to find.

Now Im searching for an way to put this together to get the following things.
1). The distance between the 2 locations.
2). The angle/degree to where the location is.

If you got some code for this please explain this, Or if you got other suggestions/links feel free to post them.
Any help would be welcome. If I find something myself Ill post it here also.


How to calculate the distance between two GPS coordinates (I found this code but how can I use this?)


Kind regards,

Cycl0ps

p.s: Im an starting java dev, so please bear with me.
p.s.s: Sorry about my bad english.
Cycl0ps
Freshman
Freshman
 
Posts: 4
Joined: Thu Apr 22, 2010 10:18 am

Top

Re: Navigation application / (layar)

Postby TieuKim » Thu Oct 21, 2010 11:13 am

Here is a method to calculation between 2 GeoPoint.


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. private final double Radius=6371000;
  3. private  double CalculationByDistance(GeoPoint StartP, GeoPoint EndP) {
  4.                       double lat1 = StartP.getLatitudeE6()/1E6;
  5.                       double lat2 = EndP.getLatitudeE6()/1E6;
  6.                       double lon1 = StartP.getLongitudeE6()/1E6;
  7.                       double lon2 = EndP.getLongitudeE6()/1E6;
  8.                       double dLat = Math.toRadians(lat2-lat1);
  9.                       double dLon = Math.toRadians(lon2-lon1);
  10.                       double a = Math.sin(dLat/2) * Math.sin(dLat/2) +
  11.                       Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) *
  12.                       Math.sin(dLon/2) * Math.sin(dLon/2);
  13.                       double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
  14.                       return Radius * c;
  15.                    }
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


try it... :D
TieuKim
Freshman
Freshman
 
Posts: 2
Joined: Sat Sep 11, 2010 11:23 am

Re: Navigation application / (layar)

Postby Openxcell » Tue Mar 29, 2011 1:23 pm

Cycl0ps wrote:Hello,

Im trying to make an application like Layar, now im comming to the hardest part of the coding.
I want can get my GPS coordinates and can call the GPS coordinates of the locations I want to find.

Now Im searching for an way to put this together to get the following things.
1). The distance between the 2 locations.
2). The angle/degree to where the location is.

If you got some code for this please explain this, Or if you got other suggestions/links feel free to post them.
Any help would be welcome. If I find something myself Ill post it here also.


How to calculate the distance between two GPS coordinates (I found this code but how can I use this?)


Kind regards,

Cycl0ps

p.s: Im an starting java dev, so please bear with me.
p.s.s: Sorry about my bad english.



You can use this code to get latitude and longitude.
Public Function fgGetLatAndLongUsingAddress(sAddress As String) As String

'This function works best with a complete address including the zip code
Dim sResponseText As String, sReturn As String

sReturn = "none"

Dim objHttp As Object, sQuery As String
sQuery = "http://rpc.geocoder.us/service/csv?address=" & Replace(sAddress, " ", "+")
Set objHttp = CreateObject("Msxml2.ServerXMLHTTP")
objHttp.Open "GET", sQuery, False
objHttp.send
sResponseText = objHttp.ResponseText
gsLastLatLongResponseText = sResponseText
Set objHttp = Nothing


If Len(sResponseText) > 0 Then
If InStr(sResponseText, "Bad Request") > 0 Then
'Do Nothing
ElseIf InStr(sResponseText, "couldn't find this address") > 0 Then
'Do Nothing
Else
If InStr(sResponseText, vbCrLf) > 0 Then
'We got more than one result
End If
If InStr(sResponseText, ",") > 0 Then
Dim aryInfo() As String
aryInfo = Split(sResponseText, ",")
sReturn = aryInfo(0) & "," & aryInfo(1)
End If
End If
End If


fgGetLatAndLongUsingAddress = sReturn

End Function

Might be useful for you.
Openxcell
Experienced Developer
Experienced Developer
 
Posts: 79
Joined: Mon Mar 28, 2011 1:59 pm

Top

Return to Map Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest