Calculate if current position is within range of GPS coordinate

Creaky

Member
Licensed User
Longtime User
For an interactive guide app I need to find out whether the user is within a particular range of a point on google maps.

I've looked through the forums and found a lot of tutorials about google maps and the map view (OSMDroid), but I can't find one that covers my question

How would you guys do it? :sign0163:
 

abdulla

Member
Licensed User
Longtime User
Find the Distance Between Two GPS Coordinate

Theoretically you would have to calculate the distance between two GPS Coordinate, Coordinate of the point and coordinate of the User , search for calculating distance between gps coordinates , you will get links to formulas to apply , once you get resulting distance you just have compare it to the needed range , you can do the math in B4A , i did that few years ago, i was working on my own GPS project , just search google for the phrase the distance or calculating the distance between two gps coordinates ,I Hope that helps, Good Luck
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
It's easier than that!

Look at the GPS library and it's Location object.

You can create two Location objects and use the Location DistanceTo method to get the distance you want.

Martin.
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
Search for this: Gps Boundary or fence

Martin created a circle lib and I commented about finding closest locations from your current location by creating a "box".

These tips may help you with your issue.

(wish I was smart enough to provide the direct link...)
 
Upvote 0

Creaky

Member
Licensed User
Longtime User
Thanks for all the replies guys, especially Martin.
I totally missed the DistanceTo method in the GPS library..

It looks like it's exactly what I need! :sign0060:
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
When it comes to mapping - Martin is the man...
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…