On Feb 16, 5:15 pm, NP <[email protected]> wrote:
> Thanks Ross,
>
> I understand this problem.

Do you?

> And wrote code like below.
>
>            var county=new Array(3);
>            county[0]="Adams_IL";
>            county[1]="Cook_IL";
>            county[2]="Lake_IL";
>            for(var i=0;i<county.length;i++){
>                var geoXml = new GGeoXml("http://vconsign.net/
> images/"+county[i]+".kml");
>                alert(geoXml.loadedCorrectly());
>                alert(geoXml.getDefaultCenter());
>                map.addOverlay(geoXml);
>            }
>
> Why alert(geoXml.loadedCorrectly()) return false and if
> geoXml.getDefaultCenter() is null instead of lat,lng even geoxml
> object loaded perfectly in google map?

At the time the alert is run, geoXml has *not* loaded. It's loaded in
the background as a separate thread. If you delay execution enough
with your alerts, then by the time map.addOverlay() is reached, geoXml
will contain a GGeoXml object because it will have come back from
Google's servers by then.

You *need* a callback function to handle what comes back.

You may be able to get this to work by having a helper function to get
closure on your variables, rather like Mike's "createMarker" function.
Something like the following, perhaps (which is untested):

  function makeGeoXml(i) {
    var geoXml = new GGeoXml("http:...",
      function() {map.addOverlay(geoXml);});
           }
  for(var i=0;i<county.length;i++){
    makeGeoXml(i)
    }

makeGeoXml is a helper function which keeps track of i and allows the
GGeoXml's callback to add it to the map -- or do anything else you
want. That helper function is called in the loop.

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