javascript - Fetch 10000 coordinates synchronously using Google Maps -
i want fetch coordinates of 10,000 line of data using google maps geocoding api, , print each line browser.
approach loop each line (contain address) , pass google maps url, parse json data lat , lng. use jquery.
problem here seems run asynchronously. have tried use recursive loop without print anything. have read set async=false dont know place it.
here current code
var x = 1; setinterval(function(){ geturl = 'parse.php?urut='+x; $.get(geturl, function(get){ url = get; }); $.getjson(url, function(data){ var lat = data.results[0].geometry.location.lat; var lang = data.results[0].geometry.location.lng; var nama = data.results[0].address_components[1].long_name; $('table').append("<tr><td>"+x+"</td><td>"+lat+","+lang+"</td><td>"+nama+"</td></tr>"); }); x++; }, 500);
any recommendation?
this snippet of code should show went wrong
function getcoords(x) { geturl = 'parse.php?urut='+x; $.get(geturl, function(url){ $.getjson(url, function(data){ var lat = data.results[0].geometry.location.lat; var lang = data.results[0].geometry.location.lng; var nama = data.results[0].address_components[1].long_name; $('table').append("<tr><td>"+x+"</td><td>"+lat+","+lang+"</td><td>"+nama+"</td></tr>"); }); }); }
the $.getjson run part of success function of $.get - therefore run once $.get complete
i've shown function, value of x
correct in $('table').append
line
Comments
Post a Comment