Hi there. I have looked around and decided that it isn't feasible to try and geocode multiple addresses... I have checked out Mike Williams great tutorials - especially for the mulitple geocoding and using a delay. The issue is that I don't entirely understand his code as I'm inexperience with Javascript:
view-source:http://econym.googlepages.com/example_geomulti.htm I was wondering if someone could explain the following code in detail to me with comments. There are several things I don't understand, such as the multiple === also I cant see where he gives delay a value. I would greatly appreciate some light on this code. Thank you very much delay// between geocode requests - at the time of writing, 100 miliseconds seems to work well var delay if = (GBrowserIsCompatible()) { Create // = a Client Geocoder var = geo GClientGeocoder(); = ===== Array // = for decoding the failure codes var = reasons reasons[G_GEO_SUCCESS]=Success ; = ""reasons[G_GEO_MISSING_ADDRESS] ; = ""reasons[G_GEO_UNKNOWN_ADDRESS] ; = ""reasons[G_GEO_UNAVAILABLE_ADDRESS] ;= ""reasons[G_GEO_BAD_KEY] ; = ""reasons[G_GEO_TOO_MANY_QUERIES] ; = ""reasons[G_GEO_SERVER_ERROR] ; = ""reasons[403] ; = "====="Geocoding // ====== function = getAddress(search, next) { geo.getLocations(search, function (result) { If // that was successful if (result.Status.code G_GEO_SUCCESS) = { Lets // assume that the first marker is the one we want var p var = lat var= lng Display= the// results in XML format var xml + search = '' + lat lng '" >="" =""><br>'; document.getElementById("message").innerHTML += xml; } // ====== Decode the error status ====== else { // === if we were sending the requests to fast, try this one again and increase the delay if (result.Status.code == G_GEO_TOO_MANY_QUERIES) { nextAddress--; delay++; } else { var reason="Code "+result.Status.code; if (reasons[result.Status.code]) { reason = reasons[result.Status.code] } var xml = ' <marker address="' + search + '" error="' +reason+ '"><br>'; document.getElementById("message").innerHTML += xml; } } next(); } ); } // ======= An array of locations that we want to Geocode ======== var addresses = [ "1060 West Addison Street, Chicago, IL", "99, rue de Rivoli, Paris 75001", "Oder, DE", "Piazza della Scala, Milano 20121", "London, UK", "1600 Pennsylvania Avenue, Washington, DC", "A totally bogus address" ]; // ======= Global variable to remind us what to do next var nextAddress = 0; // ======= Function to call the next Geocode operation when the reply comes back function theNext() { if (nextAddress < addresses.length) { setTimeout('getAddress("'+addresses[nextAddress] +'",theNext)', delay); nextAddress++; } else { document.getElementById("message").innerHTML += "</ markers>"; } } // ======= Call that function for the first time ======= theNext(); } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API" 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-API?hl=en -~----------~----~----~----~------~----~------~--~---
