Skip to content
Advertisement

Determine if Lat/Lng in Bounds

I’m interested in determining if a lat/lng location is within the bounds and looking for recommendations on a algorithm. (javascript or php)

Here is what I have so far:

JavaScript

will this work? thanks

Advertisement

Answer

The simple comparison in your post will work for coordinates in the US. However, if you want a solution that’s safe for checking across the International Date Line (where longitude is ±180°):

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement