In my application, we require the user to enter a zipcode to query for nearby locations. We use the zipcode's LatLng object to act as an origin, and then we draw an imaginary "bounding box" to query the database for all locations within that range. These locations would show up as markers on the map that the user will be able to see. We want to limit the results to about 10-15.
Example of the database:
I was thinking of using MySQL's BETWEEN
operator to query within ±2 degrees vertically and horizontally and then LIMIT n
those results, OR I could pull the entire database into PHP and then abstract it using range()
.
I'm not really sure what's the best way to approach this, so I'd appreciate it if any of you have dealt with this scenario before and could provide some insight on how to solve it.