You’ll need latitude en longitude values for your locations. If you have addresses and cities you could get them via a Google api (paid) or Open Streetmap api (fair use policy) or otherwise.
Then, you can retrieve addresses from your database where compared to your address longitude difference < x and latitude difference < y to get around 10 results. The results are within an imaginary box around your location on the map.
Then you could loop through the results and use a java action to check which 5 are closest, calculating the distance between geo locations like suggested here. Closest means “as the bird flies” btw, not driving distance or anything like that. The results now are within the smallest possible circle around your location on the map.