2

我正在使用 InfoBox 插件在谷歌地图中创建自定义交互式信息窗口。从这些信息窗口中,用户可以滚动列表并单击图像以调用某些脚本。一切正常,问题是启用 enableEventPropagation 时,我可以通过信息框单击其他标记,从而弹出另一个信息框。

有没有人有解决这个问题的经验?

InfoWindow = new InfoBox({
                            content: document.getElementById("infobox-wrapper"),
                            disableAutoPan: true,
                            enableEventPropagation: true,
                            zIndex: null,
                            pixelOffset: new google.maps.Size(-300, -0),
                            closeBoxURL: '../assets/images/info-close.png',
                            boxStyle: {
                                color: 'white',
                                background: '#101010',
                                width: "600px",
                                height: "400px"
                            },
                            infoBoxClearance: new google.maps.Size(1, 1)
                        });

删除信息框

function removeInfoWindow() {
    $('.infoBox').remove()
}

单击信息框中的图像时调用 Javascript,仅当 enableEventPropagation 设置为 true 时才有效

$(document.body).on('touchstart', '.infoBox img', function () {
    if ($(this).attr('val') == 'off') {
        //turn on
        $(this).attr('val', 'on');
        $(this).attr('src', '../assets/images/check.png');
    } else {
        //turn off
        $(this).attr('val', 'off');
        $(this).attr('src', '../assets/images/uncheck.png');
    }
});
4

0 回答 0