Frage

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!

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top