Example how to calculate distance and then take closest location.
Can be further imporved by first filtering locations to some square withing min & max lat & long. So we are not calculating distance for all locations.
I know you could use some greate Geo engine for PostgreSQL or Django but I needed fast, working solution. Feel free to use
MIT