这里有几篇与此主题相关的帖子,但我已经应用了与我读到的所有内容相关的内容:
CSS
.infoWindow {
width: 90px;
height: 90px;
}
创建信息窗口并分配给标记
var infowindow = new google.maps.InfoWindow({
content: '<div class="infoWindow">Test</div>',
maxWidth: 100
});
infowindow.open(map,test);
结果
正如您所看到的,信息窗口以最小尺寸显示,并且看不到任何文本,如果我去掉 <div>
也会出现这种情况。标签和所有样式参数,然后尝试显示“测试”。
You can check the live site yourself here (hover over top right of screen to display map)
为什么信息窗口坚持保持最小尺寸?
编辑:原来这个问题只发生在“重新加载”时,IE:当页面被缓存时。每次我清除缓存时,它都可以正常工作,但如果我重新加载页面而不清除缓存,它会显示如上图所示。 已在 Firefox 和 Chrome、OSX 上尝试过
最佳答案
尝试此解决方案,将内容放入变量中。
var content='<div class="infoWindow">Test</div>';
var infowindow = new google.maps.InfoWindow({
content:content,
maxWidth: 100
});
过去我也遇到过类似的问题,这有效。
更新
我从 Infowindow
中删除了一些选项根据this文档。
block 引用>The InfoWindowOptions object literal contains the following fields:
1)content
2)position
3)maxWidth更新2
设置
min-height
,min-width
css 属性到您的.infoWindow
类更新3
参见this您的新问题的堆栈问题
关于javascript - 无论如何,信息窗口都会显示最小尺寸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24619738/