Thanks Ross,
I understand this problem.
One thing I would like to know is , I removed call back function from
GGeoXml object.
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?
If same method I am writing inside callback function,it returns value.
I am writing this code inside java script inside salesforce s-control
so I am not able to post link for this code.
On Feb 16, 10:41 am, Rossko <[email protected]> wrote:
> > Could you please let me know fix?
>
> No, but I'll tell you what's wrong.
> If you want detailed help, you'll need to post a link and stop posting
> code.
>
> > for(var i=0;i<county.length;i++){
> > ...
> > var geoXml = new
> > GGeoXml("http://mysitename/"+county[i]
>
> +".kml", function() {
>
> > ...
>
> This is asynchronous, many people new to GMaps API struggle with the
> idea.
> See -
> http://econym.org.uk/gmap/async.htm
>
> Your loop fires off a GGeoXml request to Google's servers.
> The responses to these take ages to come back, and the javascript
> execution does NOT stop and wait for any response.
> So your loop runs around again, and fires off the next GGeoXml
> request, and so on.
>
> Your loop goes round three times and finishes, and execution carries
> on with whatever comes after the loop.
> Some time later, a response might come back from Google. It might not
> even be the first one that was sent.
> At that time, it's callback function is triggered and uses whatever
> data is set at this time.
> For example, as your loop long ago finished, 'i' will have been left
> at 3 and nothing else will change that.
> For your three GGeoXml requests, each one will run its callback
> function with 'i' set to 3.
>
> cheers, Ross K
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---