How to know if user's geo-position is close to a certain position?

1.9k views Asked by At

I'm developing a Firefox addon that detects the user's position via GPS, and then performs an action if the user is near a point. For example, it should only execute an action on the applications of green users:

enter image description here

I have the user latitude and longitude but I need to calculate if user is in the area of the other (black) point. And all of this must be done on javascript. Any idea how can do that? Or any suggestions on what I should read?

Thanks a lot!

1

There are 1 answers

0
eugmill On BEST ANSWER

For each user, calculate the distance to the center point. If that distance is less than the radius of the green circle, then perform whatever action you'd like.

As for calculating the distance between two coordinates in javascript, you can find details about that here.