In my application, we require the user to enter zipcode to request the nearest locations. We use the LatLng zipcode object to act as a source, and then we draw an imaginary "bounding box" to query the database for all locations within this range. These locations will appear as markers on the map that the user can see. We want to limit the results to about 10-15.
Example database:

I was thinking about using MySQL BETWEEN to query within ± 2 degrees vertically and horizontally, and then LIMIT n these results, OR I could pull out the whole database in PHP and then annotate it with range() .
I’m not quite sure what the best way to approach this is, so I would be grateful if one of you had previously considered this scenario and could have given some idea of how to solve it.
source share