InfoWindow关闭图标未显示在Google地图中

Dra*_*ag0 9 javascript google-maps meteor

我使用此代码创建在单击标记后显示的标记和信息窗口:

// latLng and map are created earlier in code
 var marker = new google.maps.Marker({
        position: latLng,
        map: map
    });

// contentString is just a string with content also created earlier
google.maps.event.addListener(marker, 'click', function(){
        infowindow.setContent(contentString);
        infowindow.open(map, marker);
    });
Run Code Online (Sandbox Code Playgroud)

除了一件事之外,这段代码产生的一切都很好,它不会在信息窗口的右上角显示关闭图标.

在此输入图像描述

谁知道可能是什么问题?

如果它有任何区别,我正在使用meteor.js

这就是我创建的方式InfoWindow:

var infowindow = new google.maps.InfoWindow();
Run Code Online (Sandbox Code Playgroud)

Dra*_*ag0 35

这是问题的解决方案......似乎谷歌地图有一些处理图像的有趣方式,我们认为css存在问题.所以解决方案就是将它添加到你的css文件中:

img 
{
    max-width: none;
}
Run Code Online (Sandbox Code Playgroud)

就是这样,享受吧.

  • 工作了,谢谢!我至少只会将属性设置为地图上的图像,如:`#map_canvas img {max-width:none;}`.否则网站上的每个图像都没有最大宽度(可能会破坏响应式设计) (3认同)

Kri*_*ula 12

我有同样的问题.在我的情况下,infowindow不显示指向标记的指针.在infowindow中也有一些奇怪的图像.

显然,这与bootstrap与谷歌冲突的样式表有关.以下是一个更具体的CSS,而不是覆盖一般的CSS

/** FIX for Bootstrap and Google Maps Info window styes problem **/
img[src*="gstatic.com/"], img[src*="googleapis.com/"] {
max-width: none;
}
Run Code Online (Sandbox Code Playgroud)


小智 6

根据其他CSS样式,您可能需要添加!important覆盖...

img[src*="gstatic.com/"], img[src*="googleapis.com/"] {
max-width: none !important;
}
Run Code Online (Sandbox Code Playgroud)