Location Radius Search - Laravel

Associate
Joined
14 Aug 2007
Posts
666
Location
York, UK
I'm currently building a website in Laravel & MDBootstrap with a search city or postcode function to retrieve all locations in my MySQL database within a 25 mile radius and display as cards.

My DB columns have city, full_address, longitude and latitude.

Do i need need GoogleMaps API function for this or could there be some other way? I don't need to display markers on a map or anything, just DB info within the radius of the inputted city

Many thanks
 
If you just need 'as the crow flies', you can calculate the distance between two sets of lat/long coordinates with some fairly basic maths: https://www.movable-type.co.uk/scripts/latlong.html

Depending on how big your dataset is, you might want some way of roughly narrowing it down before using this calculation. Maybe something like selecting the points with a latitude and longitude within a certain value of the search point?
 
Back
Top Bottom