Forgive me for not speaking JavaScript language very well, and feel free to correct what I say.
My purpose for using the Google Maps API v3 is to capture latitude/ longitude coordinates to store in a database for later processing. I am using the code example shown under "Geocoding Responses" on the "Google Maps Javascript API V3 Services" page. I have modified the script to pull addresses from a database and pass them one at a time to the "codeAddress()" function. The API returns the appropriate geocoded responses, but I can only see that via the alert. I need the "codeAddress()" function to pass the result back to my "getAddresses()" function for further processing. How to I get the geocoded response back to the calling function? This code can be tested at http://www.resonanceve.com/dvmta/address3.asp code: <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no"/> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <script src="_includes/jscript.js" type="text/javascript"></script> <script type="text/javascript" src="http://maps.google.com/maps/api/js? sensor=false"></script> <script type="text/javascript"> var geocoder; function initialize() { geocoder = new google.maps.Geocoder(); } function getAddresses() { var aryDtl; var user_id; var strAddress = ''; var url = 'ajax.asp?func=lstAddresses'; xmlHttp.open('get', url, true); xmlHttp.send(null); xmlHttp.onreadystatechange = function() { if (xmlHttp.readyState == 4) { alert(xmlHttp.responseText); var aryRS = xmlHttp.responseText.split("^"); for (var x = 0; x < 3; x++) { aryDtl = aryRS[x].split("~"); user_id = aryDtl[0]; strAddress = strAddress + user_id + ',' + codeAddress(aryDtl[1]) + '<br />'; } } } document.getElementById('addressDiv').innerHTML = strAddress; } function codeAddress(address) { if (geocoder) { geocoder.geocode({ 'address': address }, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { alert(results[0].geometry.location); } else { alert("Geocode was not successful for the following reason: " + status); } }); } } </script> </head> <body style="margin:0px; padding:0px;" onload="initAJAX();initialize();getAddresses();"> <div id="addressDiv"></div> </body> </html> -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.
