【问题标题】:Error displaying infowindow for marker显示标记的信息窗口时出错
【发布时间】:2013-11-26 22:08:57
【问题描述】:

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

错误

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;


    });

【问题讨论】:

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


    【解决方案1】:

    IIRC,this 在包含:infowin.open(map, this); 的行上不指代marker

    【讨论】:

    • 我试过 roadBlockMarker 而不是这个,但我没有工作同样的错误
    猜你喜欢
    • 2016-07-27
    • 2013-09-02
    • 2011-02-24
    • 1970-01-01
    • 1970-01-01
    • 2021-04-21
    • 2016-04-29
    • 2018-10-23
    • 2012-06-06
    相关资源
    最近更新 更多