On Apr 2, 8:46 am, TerriLyn <[email protected]> wrote: > All, > > I have a query that returns addresses from a database. I have then > stored the addresses in a javascript array. > > I'm trying to figure out how to display the markers for each point in > the array on the map, but I can't seem to figre out how to do so. I > know I'd need to geocode them, etc. However, I can't do that either. > (Example process follows:) > > 1. Go to the locator page ont he website. > 2. Click on the state name. > 3. Google map centered over state displays. (This is where I need the > markers from the array to show on the map.) With listing information > below the map. > 4. User clicks on a "map it" link under the listing. > 5. In the infowindow that pops up is a link to "get directions" and > the user clicks on that to get a full new browser window with the > address already plotted, so that the user can use a full Google Map > experience. > > I've been trying to get the locations to return their lat/lng pairing > via the following code and triggering it in an alertbox. Though, as of > yet, all I return is "undefined": > > for (var i = 0; i < locations.length; i++) { > alert(locations[i]); //Testing to ensure that the address, eg 1600 > Penn. Ave Wash DC is returned. > alert(geocoder.getLatLng(locations[i].toString())); //hopefully > this should return the lat/lng, right?
The geocoder is asynchronous. Part 2 Asynchronous I/O http://econym.org.uk/gmap/async.htm See the working examples in Mike Williams tutorial: http://econym.org.uk/gmap/ http://code.google.com/apis/maps/documentation/reference.html#GClientGeocoder.getLatLng getLatLng(address:String, callback:function) Takes 2 arguments. The second is a function that is called when the data is available. geocoder.getLatLng(locations[i].toString(), function(point) {alert (point);}); will alert the coordinates as the data is available... -- Larry > > } > > Any insights anyone could share would be great. > > Thanks, > -TerriLyn --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
