[thelist] Zip Code Distance From

Jason Handby jason.handby at corestar.co.uk
Wed Mar 28 11:15:19 CDT 2007

Hi Casey,

> In ASP.NET, does anyone know if there is an existing class available?
> I've been searching MSDN with no luck, but it's possible I don't know
> where or how to look.  I know there are 3rd party tools which do this,
> and that might be an option after exhausting the "free" option.

It looks like the Geocoder web service is free, and has C# sample code


To find all pizza places within 100 miles of a zip code:

1) when you first set up your site, use geocoder once for each pizza
place to get the latitude and longitude of its zip code. Store these
somewhere. (You'll also need to do this for any pizza places you add in
the future.)

2) when a user puts in their zip code, use geocode to convert it to
latitude and longitude.

3) use some maths to work out which pizza place's coordinates fall
within a circle of 100 miles radius whose centre is at the coordinates
of the user's zip code. You'll probably have to convert your chosen
radius from miles to whatever units the latitude and longitude are in.
Using pythagoras will be quicker than sine and cosine :-)

Hope this helps!


More information about the thelist mailing list