On Dec 19, 7:23 pm, "sham rao" <[email protected]> wrote:
>
> If I use msg as global variable, only the last msg is saved on the
> infowindow for both the markers.

Yes. If you use a global variable, it's global! You need to create a
local variable, and a helper function to keep closure on it.

The documentation example at
http://code.google.com/intl/fr/apis/maps/documentation/services.html#Geocoding_Object
shows how to pass a variable to a function which does the geocoding,
and keep the value of that variable.

You could use and alter that example to

showAddress("1600 Amphitheatre, etc","California");
showAddress("Millennium etc","Atlanta");

function showAddress(address,msg) {
  geocoder.getLocations(address, function(response) {
  ...

putting your addAddressToMap function *inside* the showAddress
callback. Because it's inside showAddress, the callback function can
make use of address and msg passed to showAddress.

Andrew
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to