All pastes #811425 Raw Edit

Ratty

public text v1 · immutable
·published 2007-12-10 22:13 UTC
rendered paste body
        init_markers: function()
        {
                request = GXmlHttp.create();
                request.open('GET', '/maps/getall/', true);

                request.onreadystatechange = GEvent.callback(this, function() {
                        if (request.readyState == 4) {
                                var xmlDoc = request.responseXML;
                                var markers = xmlDoc.documentElement.getElementsByTagName("marker");

                                for(i=0;i<=markers.length-1;i++)
                                {
                                        x = markers[i].getElementsByTagName('x')[0].firstChild.nodeValue;
                                        y = markers[i].getElementsByTagName('y')[0].firstChild.nodeValue;
                                        desc = markers[i].getElementsByTagName('desc')[0].firstChild.nodeValue;

                                        //Add markers to the map
                                        var marker = new GMarker( new GPoint(x,y) );
                                        var html = '<h2>Marker!</h2><p>' + desc + '</p>';

                                        this.addOverlay(marker);

                                        GEvent.addListener(marker, 'click', function() {
                                                marker.openInfoWindowHtml(html);
                                        });
                                }
                        }
                });
                request.send(null);
        },