> Here you got my uploaded map:http://dots.axesgame.com/map/

Your createMarker() function is defined inside your initialize()
function.
That means when initialize() has finished, createMarker won't exist
anymore.

GDownloadUrl is asynchronous, you kick it off, and some time later the
data comes back and it will run the anonymous function() you asked you
it to, which includes the marker creating loop.

But "asynchronous" means it doesn't stop and wait when the request to
fetch data has been made.  javascript execution continues ... in fact
there isn't any more code to execute, so initialize() finishes - long
before the data gets back.  When the data does get back, createMarker
exists no more and an error is generated.

You probably want to define createMarker() in global scope to avoid
this pitfall.

cheers, Ross K




>
> I have been trying to copy the 'Loading the data from XML'-tutorial,
> while removing the crap that was the sidebar.
> The original code comes from the first example 
> at;http://www.google.com/apis/maps/documentation/
>
> I have copied this info from;http://econym.org.uk/gmap/basic3.htm
>
> "      function createMarker(point,name,html) {
>         var marker = new GMarker(point);
>         GEvent.addListener(marker, "click", function() {
>           marker.openInfoWindowHtml(html);
>         });
>
>       GDownloadUrl("example.xml", function(doc) {
>         var xmlDoc = GXml.parse(doc);
>         var markers = xmlDoc.documentElement.getElementsByTagName
> ("marker");
>
>         for (var i = 0; i < markers.length; i++) {
>           // obtain the attribues of each marker
>           var lat = parseFloat(markers[i].getAttribute("lat"));
>           var lng = parseFloat(markers[i].getAttribute("lng"));
>           var point = new GLatLng(lat,lng);
>           var html = markers[i].getAttribute("html");
>           // create the marker
>           var marker = createMarker(point,html);
>           map.addOverlay(marker);"
>
> The stuff pointing to a label has been removed since that was for the
> sidebar.
>
> Later i will add custom markers in this 
> way;http://econym.org.uk/gmap/example_custom.htm
>
> As you can see, the map doesnt load after i have added the xml loading/
> creating marker stuff.
> So i must have missed something.
--~--~---------~--~----~------------~-------~--~----~
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