Google Maps: Find all zip codes along route -


given 2 locations can calculate route in google maps.

  1. is possible find zip codes along route?
  2. given zip code, can expand area 10 km radius , find zip codes in area?

what methods should use information? tutorials welcome. don't need complete working solution, although if 1 available nice.

you need data source containing zipcode (zcta) polygons. 1 possible source this fusiontable.

proof of concept

proof of concept showing zcta polygons

note: since queries zip code @ every point along route, take longer finish longer route is.

code performs query (using google visualization api):

function queryforzip(latlng) {   //set query using current latlng   var querystr = "select geometry, zip, latitude, longitude "+ tableid + " st_intersects(geometry, circle(latlng"+latlng+",1))";      var querytext = encodeuricomponent(querystr);   var query = new google.visualization.query('http://www.google.com/fusiontables/gvizdata?tq='  + querytext);    //set callback function   query.send(addzipcode); }    function addzipcode(response) { if (!response) {   alert('no response');   return; } if (response.iserror()) {   document.getelementbyid('status').innerhtml += 'error in query: ' + response.getmessage() + ' ' + response.getdetailedmessage()+"<br>";   return; }    ftresponse = response;   //for more information on response object, see documentation   //http://code.google.com/apis/visualization/documentation/reference.html#queryresponse   numrows = response.getdatatable().getnumberofrows();   numcols = response.getdatatable().getnumberofcolumns();   for(i = 0; < numrows; i++) {       var zip = response.getdatatable().getvalue(i, 1);       var zipstr = zip.tostring()       if (!zipcodes[zipstr]) {         zipcodes[zipstr] = zipstr;         document.getelementbyid('zipcodes').innerhtml += zipstr+"<br>";       }   } } 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -