Question

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!

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top