Looking to Build/Redesign a Website or Blog ?

To speak to Rakshit, call +91 968 704 2303

Find a Lat/Long with in x miles/kilometer Radius

Hello Friends,

You are at the right place if you are looking for solution to get or check latitude and longitude is with in x miles of radius with given latitude and longitude. This is very easy with a single equation. Get all lat/long list from database if current lat/long is with in x miles of radius.

For Miles:

((ACOS(SIN(‘.$latitude.’ * PI() / 180) * SIN(latitude * PI() / 180) + COS(‘.$latitude.’ * PI() / 180) * COS(latitude * PI() / 180) * COS((‘.$longitude.’ – longitude) * PI() / 180))* 180 / PI()) * 60 * 1.1515) AS distance

For Kilometers:

(((ACOS(SIN(‘.$latitude.’ * PI() / 180) * SIN(latitude * PI() / 180) + COS(‘.$latitude.’ * PI() / 180) * COS(latitude * PI() / 180) * COS((‘.$longitude.’ – longitude) * PI() / 180))* 180 / PI()) * 60 * 1.1515)*1.609344) AS distance

Let me know if you find any problem.

Thank you!

Share:

2 Comments

Leave a Reply

Your email address will not be published.