On Jun 21, 7:39 pm, NNS NNS <[email protected]> wrote:
> Hi guys,
>
> I must admit I am rather a n00b at programming and Javascript in
> general, so please keep that in mind. I'm trying to do what this
> article is suggesting:http://code.google.com/apis/maps/articles/
> phpsqlajax.html

May I suggest reading this from the posting guidelines:
http://www.catb.org/%7Eesr/faqs/smart-questions.html#bespecific


>
> ...but also make it so each marker is created as an object/variable
> that can be used to mess around afterward.
>
> This is what my website currently looks like:www.mtlparking.com
>
> This is what is it supposed to look like:www.mtlparking.com/

And the difference between those two links is?
They look identical to both my eyeballs and my browser.

>
> Code snippet:
>
>                 plist = new Array();
>
>                 GDownloadUrl("outputXML2.php", function(data) {
>   var xml = GXml.parse(data);
>   var markers = xml.documentElement.getElementsByTagName("marker");
>   for (i = 0; i < markers.length; i++) {
>     var id = markers[i].getAttribute("id");

Your xml:
http://www.mtlparking.com/outputXML2.php

doesn't have an attribute "id".

This is also a problem:
document.write(rank[1] + "<br>");

As is this redundant call (line 727):
load();


>     var name = markers[i].getAttribute("name");
>     var address = markers[i].getAttribute("address");
>     var point = new
> GLatLng(parseFloat(markers[i].getAttribute("lat")),
>
> parseFloat(markers[i].getAttribute("lng")));
>         var icon = markers[i].getAttribute("icon");
>         var pw = markers[i].getAttribute("pw");
>
>      plist[i] = new demo(id, point, address, name, icon, pw);
>
>         GEvent.addListener(plist[i].markerz, 'mouseover', function()
>         {
>                 plist[i].markerz.openInfoWindowHtml(plist[i].html)}

Your real problem is in the line above.  You are not getting function
closure on "i", so when I mouse over any marker, it is equal to 13,
and the plist array only has 12 elements.

You could look at pitfall #3 here:
The Basics - Part 1 Markers with info windows
http://econym.org.uk/gmap/basic1.htm

or:
Javascript Concepts - Part 3 Function Closure
http://econym.org.uk/gmap/closure.htm

  -- Larry


>         );
>
>     map.addOverlay(plist[i].markerz);
>
>       // alert(plist[i].name);
>     }
>
> ...
> (later on)
>
>         function demo(id, point, address, name, icon, pw)
>                 {
>                 this.id = id;
>                 this.add = address;
>                 this.name = name;
>                 this.markerz = new GMarker(point, icon);
>                 this.pw = pw;
>                 this.html = name + address;
>                 this.icon;
>                 }
>
> Sorry if this is a n00b question, it's frustrating me to no end. I've
> really messed around and tried a lot of different things also, but
> then the API gives me undecipherable error messages like 'a
> undefined'.
>
> Thanks folks

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