On Feb 9, 7:11 pm, mdecourcy <[email protected]> wrote: > Maybe I'm just tired and I'm missing something obvious. > > This code using lat/long in one function works, zooms and center > properly:
It doesn't use the geocoder, which is asynchronous... > > See here:http://vcigroupinc.no-ip.com/mapTest2.asp > > But this code where I use an array of addresses and two functions > doesn't: > <script> > var arrAddress = ["1101 N. Lake Destiny Road, Maitland, FL 32751", > "224 Datura Street, West Palm Beach, FL 33401", "1451 W. Cypress Creek > Road, Ft. Lauderdale, FL 33309", "13101 Northwest Freeway, Houston, TX > 77040"]; > This loop fires off a bunch of requests for geocoded results: > for (i=0; i<arrAddress.length; i++) { > geocoder.getLocations(arrAddress[i], addToMap); > } Then this code runs, none of the results have come back yet, so bounds is empty (the whole world...) > map.setZoom(map.getBoundsZoomLevel(bounds)); > map.setCenter(bounds.getCenter()); > } Sometime later these functions are called with the results (if any) and add any points that were returned to the map: > function addToMap(response) { > place = response.Placemark[0]; > marker = new GMarker(new GLatLng(place.Point.coordinates[1], > place.Point.coordinates[0])); > map.addOverlay(marker); > bounds.extend(marker.getPoint());} See: Javascript Concepts Part 2 Asynchronous I/O http://econym.org.uk/gmap/async.htm -- Larry > See here:http://vcigroupinc.no-ip.com/mapTest.asp --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
