#1
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2004
    Posts
    566
    Rep Power
    11

    Sort array of locations - zipcodes on Google back-end


    Hi,
    Does anybody know whether this is possible:

    There is an array of zipcodes:
    zipcodes length might be around 100

    var zipcodes = new Array("90037","10162","80260","33101","02201","30311","98102","15238","66103", ...);

    User enters zipcode e.g. 73101 into search box
    Google API returns JSON - sorted array based on distance.


    If the above is not possible could I at least get all those distances with one request?

    Thank you.
    Last edited by sqluppo; June 6th, 2013 at 10:40 AM.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2006
    Posts
    40
    Rep Power
    9
    I think you need to take a closer look at google address api documentation found here
    https://developers.google.com/maps/
  4. #3
  5. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,158
    Rep Power
    184
    Originally Posted by sqluppo
    Hi,
    Does anybody know whether this is possible:

    There is an array of zipcodes:
    zipcodes length might be around 100

    var zipcodes = new Array("90037","10162","80260","33101","02201","30311","98102","15238","66103", ...);

    User enters zipcode e.g. 73101 into search box
    Google API returns JSON - sorted array based on distance.


    If the above is not possible could I at least get all those distances with one request?

    Thank you.
    You can do this... that's the good news; because I was interested in what you were wanting to do, so I took the time to create a little something (based on what you are wanting to do). Ok, now here's the bad news... Google limits the amount of simultaneous calls you can make to their JSON MAP API; within "X" amount of seconds/minutes/hours/etc. I cannot give you a definitive number of calls you can make @ once, but it will shut down the service to you for seconds or even up to 24 hours (per their terms of use policy - pertaining to this specific API); if you surpass that limit. There is hope though; if you really are vested in this idea and want to have more freedom, probably to make unlimited calls to the JSON API; you can sign-up for their business service. So to sum this up... yes, it can be done; but with limitations, without forking over some cash to Google.

IMN logo majestic logo threadwatch logo seochat tools logo