you need to have a table which as full usa miles with the state and cities. then you will calculate the start point with distination and get your result, but remember when i said full miles of usa thats not mean just get each miles of city.
example:
wronge.
NY miles = 300,000;
NJ miles = 258,987;
right:
NY miles = 300,000;
NJ miles = 528,987;
get the full usa miles with state and cities without getting sperated from each other.
this will take lots of time, i recommand to drop the option for getting within miles. just give them option for zip code to zip code.