Getting a strange error when trying to create InfoWindows in Google Maps V3-Collection of common programming errors

I am getting the error “Uncaught TypeError: Object # has no method ‘L'” whenever I interact with either a marker or polyline in my map that has an InfoWindow that is supposed to open on click event. The marker InfoWindow opens with the error and I cannot close it, and the InfoWindow will not open at all for my polylines. Here is the code:

function downloadUrl(url,callback) {
    var request = window.ActiveXObject ?
        new ActiveXObject('Microsoft.XMLHTTP') :
        new XMLHttpRequest;
    request.onreadystatechange = function() {
        if (request.readyState == 4) {
            request.onreadystatechange = doNothing;
            callback(request, request.status);
        }
    };
    request.open('GET', url, true);
    request.send(null);
}

function doNothing() {}

function decodeLevels(encodedLevelsString) {
    var decodedLevels = [];

    for (var i = 0; i < encodedLevelsString.length; ++i) {
            var level = encodedLevelsString.charCodeAt(i) - 63;
            decodedLevels.push(level);
    }
        return decodedLevels;
}

function createPolyLine(span_id, desc, encoded_span, plevels, pcolor, pweight, popacity) {
    var decodedPath = google.maps.geometry.encoding.decodePath(encoded_span);
    var decodedLevels = decodeLevels(plevels);

    var polyline = new google.maps.Polyline({
            path: decodedPath,
            levels: decodedLevels,
            strokeColor: pcolor,
            strokeOpacity: popacity,
            strokeWeight: pweight,
    });

    // Custom polyline events
    //--------------------------------------------------------
    var html = "[" + span_id + "] " + desc;

    google.maps.event.addListener(polyline, 'click', function(event) {
        var infowindow = new google.maps.InfoWindow({
                content: "infowindow text content"});
        infowindow.position = event.latLng;
        infowindow.open(map);
    });

    //--------------------------------------------------------

    return polyline;
}

function createMarker(point, name, address, clli, type, site_id, site_name) {
    var html = "

" + name + "

" + "
" + address + "
" + clli + "
View POP"; var marker = new google.maps.Marker({ position: point, //map: map, }); // Custom marker events //-------------------------------------------------------- google.maps.event.addListener(marker, 'click', function() { var infowindow = new google.maps.InfoWindow({ content: html }); infowindow.open(map,marker); }); //-------------------------------------------------------- return marker; } function initialize() { var infowindow; var latlng = new google.maps.LatLng(44.247904,-90.46225); var opt = { center:latlng, scrollwheel: false, zoom:8, mapTypeId: google.maps.MapTypeId.ROADMAP, disableAutoPan:false, navigationControl:true, navigationControlOptions: {style:google.maps.NavigationControlStyle.ZOOM_PAN }, mapTypeControl:true, mapTypeControlOptions: {style:google.maps.MapTypeControlStyle.DROPDOWN_MENU} }; downloadUrl("gen_span_xml_v3.php", function(data) { var xml = data.responseXML; var spans = xml.documentElement.getElementsByTagName("span"); for (var i = 0; i < spans.length; i++) { var span_id = spans[i].getAttribute("id"); var desc = spans[i].getAttribute("desc"); var encoded_span = spans[i].getAttribute("encoded"); var levels = spans[i].getAttribute("levels"); var encodedPolyline = createPolyLine(span_id, desc, encoded_span, levels, '#0055ff', '4', '.5') encodedPolyline.setMap(map); } }); downloadUrl("gen_marker_xml.php", function(data) { var xml = data.responseXML; var markers = xml.documentElement.getElementsByTagName("marker"); for (var i = 0; i < markers.length; i++) { var name = markers[i].getAttribute("name"); var address = markers[i].getAttribute("address"); var clli = markers[i].getAttribute("clli"); var type = markers[i].getAttribute("type"); var site_id = markers[i].getAttribute("site_id"); var site_name = markers[i].getAttribute("site_name"); var point = new google.maps.LatLng( parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng"))); var new_marker = createMarker(point, name, address, clli, type, site_id, site_name); new_marker.setMap(map); } }); var map = new google.maps.Map(document.getElementById("map"),opt); }

Originally posted 2013-11-15 09:08:58.