如何更改InfoWindow背景颜色 [英] How to change the InfoWindow Background color

查看:2014
本文介绍了如何更改InfoWindow背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我面临这个问题,我的谷歌地图API显示默认的InfoWindow背景颜色为白色。我想将白色改为黑色。
REF CODE:

$ p $ google.maps.event.addListener(marker,'mouseover',function(){


infoWindow.setContent(html);
infoWindow.open(map,marker);
//infoWindow.setStyle(\"background-color:red);


});


解决方案

我想出了一个简单的解决方案。这可能不是一个非常优雅的解决方案,但它可以很好地工作,如果你没有很大的样式需求。



因为我们可以添加自己的html并对其进行设计。标记背景元素主要是导致问题的元素。对于简单的样式,而不是学习一个全新的库,我们可以使用jQuery删除该元素。



在init函数中插入这段代码,它将删除背景元素。

  google.maps.event.addListenerOnce(map,'idle',function(){
jQuery('。gm-style-iw')。prev('div')。remove();
});

现在,您可以自由设计自己的div。我使用这种方法在我的项目中设计了infoWindow。



希望它能帮上忙。


I'm facing the problem,My google Map API showing default InfoWindow with background color white.I want change the White color to Black color. REF CODE:

google.maps.event.addListener(marker, 'mouseover', function() {


    infoWindow.setContent(html);
        infoWindow.open(map, marker);
               //infoWindow.setStyle("background-color: red");


      });

解决方案

I came up with a simple solution. This might not be a very elegant solution but it works fine if you don't have huge styling needs.

Since we can add our own html and style it. The marker background element is mainly the one which causes problem. For simple styling, instead of learning a whole new library, we can just remove that element using jQuery.

Insert this code in your init function and it will remove the background element.

google.maps.event.addListenerOnce(map, 'idle', function(){
    jQuery('.gm-style-iw').prev('div').remove();
}); 

Now, you are free to style your own divs. I styled the infoWindow in my project using this approach.

Hope it will help.

这篇关于如何更改InfoWindow背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆