Finlay found solution.
I call the Next() method inside load() funciton and wrote call like
this.
function theNext() {
var county=new Array(3);
county[0]="Adams_IL";
county[1]="Cook_IL";
county[2]="Lake_IL";
if (nextAddress < county.length) {
setTimeout('getAddress("'+county[nextAddress]+'",theNext)',
200);
nextAddress++;
}
}
function getAddress(county1, next){
var name=county1.split("_");
var geoXml = new GGeoXml("http://vconsign.net/
images/"+county1+".kml", function() {
if (geoXml.loadedCorrectly()) {
alert(geoXml.getDefaultCenter());
geoXml.gotoDefaultViewport(map);
center= geoXml.getDefaultCenter();
var label = new ELabel(geoXml.getDefaultCenter(),name
[0], "style1");
map.addOverlay(label);
}
});
map.addOverlay(geoXml);
next();
}
and it placed all three kml file with label on center.
-Thanks for all reply.
On Feb 16, 11:26 am, "warden [Andrew Leach - Maps API Guru]"
<[email protected]> wrote:
> 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- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---