又快又脏
var infowindow = new google.maps.InfoWindow({
content: '<div id="iw_content"><a href="/" style="color:#f00">3434</a> <a href="/" style="color:#00f">4</a> <a href="/" style="color:#0f0">18-9</a></div>'
});
google.maps.event.addListener(infowindow,'domready',function(){
var el = document.getElementById('iw_content');
//* Get and set a class for the main content containers container
el = el.parentNode.parentNode;
el.setAttribute('class','iw_content_container_container');
//* Get and set a class for the div containing the close window image
closeEl = (el.previousElementSibling)?el.previousElementSibling:el.previousSibling;
closeEl.setAttribute('class','closeInfoWindow');
//* Get and set a class for the div containing the close and main content
el = el.parentNode;
el.setAttribute('class','closeInfoWindowContainer');
//* Get and hide the troublesome background
el = (el.previousElementSibling)?el.previousElementSibling:el.previousSibling;
el.style.display = "none";
//* Get and hide the top image of the arrow
el = (el.previousElementSibling)?el.previousElementSibling:el.previousSibling;
el.style.display = 'none';
//* Get and hide the shadow (hiding commented out for now as not strictly requested)
el = el.parentNode.parentNode;
el = (el.previousElementSibling)?el.previousElementSibling.previousElementSibling:el.previousSibling.previousSibling;
//el.style.display = 'none';
});
这可能对您有用,可以在代码中放置一些钩子,然后您可以使用 css 处理这些钩子
#iw_content{background:#fff}
.iw_content_container_container{height:auto!important;text-align:center}
.closeInfoWindow {top:22px!important;right:22px!important}
.closeInfoWindowContainer{position:absolute;top:52px;height:auto!important}
您可能想弄乱 .closeInfoWindowContainer 的最高值,因为这取决于文本的数量。基本上只用你的那一行测试过。
我实际上尝试在代码本身中删除宽度和高度(因此在 javascript 中添加/更改),但地图有一个令人讨厌的习惯,即根据加载时光标的状态和位置将它们重新放回。
...
信息窗口是可点击的。它们只是页面中的普通 div 元素,可以这样对待。我在您的示例超链接中设置了各种值来显示这一点。
抱歉,这不是 wicketstuff,但我认为我仍然应该发布解决方案。