Javascript 从谷歌地图信息窗口中删除关闭图标

Javascript 从谷歌地图信息窗口中删除关闭图标,javascript,Javascript,如何删除谷歌地图信息窗口的关闭图标。我试图删除此图标,但找不到该图标的id或类 有人能帮我从信息窗口中删除关闭图标吗?对于使用谷歌地图API v2的用户,此功能将打开一个没有关闭图标的信息窗口: openInfoWindowHtml(html, { maxWidth: 200, buttons: { close: { visible: false } } }); 您可以使用CSS隐藏关闭按钮: .gm-style iw+div{display:none;} 我将选项对象上的closeBox

如何删除谷歌地图信息窗口的关闭图标。我试图删除此图标,但找不到该图标的id或类


有人能帮我从信息窗口中删除关闭图标吗?

对于使用谷歌地图API v2的用户,此功能将打开一个没有关闭图标的信息窗口:

openInfoWindowHtml(html, {
  maxWidth: 200, buttons: { close: { visible: false } }
});

您可以使用CSS隐藏关闭按钮:

.gm-style iw+div{display:none;}

我将选项对象上的
closeBoxURL
设置为空字符串

infoboxOptions = {

    closeBoxURL: '',
    ...

}

var infobox = new InfoBox(infoboxOptions);

我尝试了上面所有的建议,但都失败了。我尝试使用jquery
$('.gm-style-iw')。next().hide()
,但效果不佳

这对我来说很有用,以防有人需要。这就是我用GMAPAPIv3所做的

.gm-style .gm-style-iw + div {
    display: none; /* <-- this will generally work on the fly. */
    visibility: hidden; /* this 2 lines below are just for hard hiding. :) */
    opacity: 0;
}
.gm-style.gm-style-iw+div{
display:none;/*您可以试试这个

.gm-style-iw + div{ display: none; } // hide div

.gm-style-iw + div + img{ display: none; } // hide img 
::ng-deep .gm-style .gm-style-iw-c button {
    display: none !important;
}

这对我来说只是css

.gm-ui-hover-effect {
    display: none !important;
}
现在在Chrome和Edge中仍然有效,您可以试试这个

.gm-style-iw + div{ display: none; } // hide div

.gm-style-iw + div + img{ display: none; } // hide img 
::ng-deep .gm-style .gm-style-iw-c button {
    display: none !important;
}
其中的魔力是::ng deep修饰符,它可以深入搜索样式并覆盖它们

.gm-style-iw button>img {
    display: none!important;
}
此代码段将使其正常工作。在我的示例中,表示关闭按钮的图像位于div classed gm style iw中的按钮标记内

button.gm-ui-hover-effect {
   visibility: hidden;
}

这在Maps API v3.43中非常有效。我的示例代码
marker.setMap(map);$('body').append('')$(“#targetdiv”).load('ProgressBar1.jsp');var innerhtml=document.getElementById(“targetdiv”);var infowindow=new google.Maps.infowindow({内容:innerhtml,maxWidth:200,按钮:{close:{visible:false}},};infowindow.open(map,marker);//openInfoWindowHtml(document.getElementById(“targetdiv”),{maxWidth:200,按钮:{close:{visible:false}});marker.setMap(map);
您已经有了代码:
按钮:{close:{visible:false}
。应该可以,你使用的是什么浏览器?我使用的是mozilla firefox 24.0。这个答案已经过时。它适用于Google不再支持的Google Maps API 2。新的API没有openInfoWindowHtml功能。