编程语言
首页 > 编程语言> > javascript-显示标记的信息窗口时出错

javascript-显示标记的信息窗口时出错

作者:互联网

我有一个返回一个对象的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;


    });

解决方法:

IIRC,此行包含:infowin.open(map,this);不涉及标记.

标签:infowindow,google-maps,google-maps-markers,javascript
来源: https://codeday.me/bug/20191030/1966084.html