显示标记的infowindow时出错

时间:2013-11-14 02:38:24

标签: javascript google-maps google-maps-markers infowindow

我有一个ajax请求,它返回一个对象但是我试图在infowindow中为标记显示对象数据但是我收到一个错误:

错误

TypeError: a.get is not a function

Ajax请求 - 信息窗口未打开

google.maps.event.addListener(roadBlockMarker, "click", function () {
        //passing data to dialog
        $("#roadblockmarker-dialog").data("recordId", recordId);

        if (clicks) { //Double Click
            clicks = false; //reset
            clearTimeout(clicksTimeout);
            alert('Double Click');
            //send an ajax request to scheck the roadblock status in order to enable and disable buttons on dialog


            //set a reference to the marker clicked and then open the dialog for other options
            $("#roadblockmarker-dialog").dialog("option", {
                marker: this
            }).dialog("open");

        } else { //Single Click
            clicks = true;
            clicksTimeout = setTimeout(function () {
                clicks = false;
                alert('Single click');
                //do double click function here
                //Make ajax request to get infowindow data
                $.ajax({
                    type: 'GET',
                    url: 'getRoadBlockInfoWindowData.htm',
                    async: 'false',
                    cache: 'false',
                    data: {
                        roadBlockId: recordId
                    },
                    dataType: 'json'

                }).success(function (roadBlock) { //display info window here with data
                    var infowin = new google.maps.InfoWindow({
                        content: roadBlock.purpose
                    });
                    infowin.open(map, this);
                    console.log('success ' + roadBlock.purpose);


                });
            }, 300);

        }
        return false;


    });

1 个答案:

答案 0 :(得分:4)

IIRC,this在包含infowin.open(map, this);的行中未引用marker