Free SW For "Closest Store"

I want to put one of those cool “find the closest store” thingys on our wholesale website so that user’s of our products can find a retailer near them. Is there free code somewhere I can use to do this?

You MIGHT be able to use the Google Maps API to get it sorted out but I am not completely sure how to do it. You’d have to do some research.

We built a “nearest location” app for one of our customers but it involved purchasing some zip code data, which is not really cheap. Handy, though.

I looked at the Google Map API and it seemed more geared towards creating maps with the specified locations. I want to get a list of the N closest stores. There are some free geocoding services which give coordinates based on addresses, but I’m not sure how I go from coodinates to distance.