GDownloadUrl is asynchronous. That is to say: what it does, it does in  
its own time. There is absolutely no guarantee that the callback (in  
your case, CheckDataAndResponse) will occur before the lines of code  
following it. And in your case, it clearly *isn't* being completed  
before those lines of code. You are trying to parse the xml (contained  
in markerdata) before the xml has even completed downloading.  
Therefore, you must adjust your code so that you only try to use that  
data once it is ready. I still don't see why you can't adopt the  
suggestion I made: any time you want to update the map without  
reloading the entire page, you would then simply clear the old markers  
and call GDownloadUrl("data.xml", CheckDataAndResponse);  
again...CheckDataAndResponse is only called once the operation is  
complete, which is why all your data-handling should be activated by  
that callback.

-G

On Jul 23, 2009, at 9:08 AM, guido wrote:

>
> Hi Gregory,
>
> On 23 Jul., 15:59, Gregory Short <[email protected]> wrote:
>>      function parseMarkerData()
>>      {
>>          var xml = GXml.parse(data); // <--- Where is "data" being
>> defined?
>>          return xml.documentElement.getElementsByTagName("marker");
>>      }
>> Perhaps you meant "markerdata"...
>
> yes sure. I changed the variable name a few minutes ago. I have
> corrected this. But I think you understood the problem cause...
>> but then you have problems with the
>> asynchronous nature of GDownloadUrl
>
> I don't know nothing about this. I do all this with the markers, cause
> I want to create automatically moving markers on a map without
> reloading the map each time. Therefore I have to seperate the loading
> of the map the reading of the markers and the craeting of the markers
> as well.
>
>> ...One solution might be to fire
>> off the chain of function calls that parses the xml and populates the
>> map from within CheckDataAndResponse.
>> On Jul 23, 2009, at 8:41 AM, guido wrote:
>
> As you may understand this wouldn't be possible I think.
>>
>>
>>
>>
>>
>>> Hi @all
>>
>>> I have a problem using GDownloadUrl and accessing the data coming  
>>> into
>>> the callback function. I must say that I am really new to Google  
>>> maps
>>> and to Javascript so please be patient. The link to my site is
>>> http://status.taxikomm24.de/10/index_neu.html
>>
>>> As you can see if the callback function "CheckDataAndResponse" is
>>> called all the data is perfectly there. But as soon as I want to
>>> access the variable makerdata, which is defined as global, in the
>>> function "INITMap". The variable markerdata is undefined.
>>
>>> Please can someone help me with this. Any suggesition is welcome.
>>
>>> Thanks..Guido- Zitierten Text ausblenden -
>>
>> - Zitierten Text anzeigen -
> >


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