问题描述
Google地图可以有透明的背景色吗?我一直在搞参数,但是找不到解决方案.我正在使用JS API.
Can google maps have a transparent bg? I've been messing with the paramaters but can't find a solution. I'm using the JS API.
谢谢.
推荐答案
有一种方法可以通过Google Maps API V3为地图提供透明背景. MapOptions 对象具有名为backgroundColor
的属性,设置地图的背景色.如果使用HSLA颜色值,则可以控制此背景颜色的不透明度来创建透明度.
There is a way to give the map a transparent background with Google Maps API V3. The MapOptions object has a property called backgroundColor
, which sets the background colour of the map. If you use an HSLA color value, you can control the opacity of this background colour to create the transparency.
var mapOptions = {
zoom: 1,
styles: mapStyles,
backgroundColor: 'hsla(0, 0%, 0%, 0)',
};
除了设置这种颜色外,还需要使用一些地图样式来隐藏水(或任何想要透明的东西).
In addition to setting this color, you also need to use some map styles to hide the water (or whatever you want to be transparent).
这是一个演示效果的codepen: http://codepen.io/verticalgrain/pen/LVRezx
Here is a codepen demonstrating the effect:http://codepen.io/verticalgrain/pen/LVRezx
这篇关于谷歌地图可以有透明的背景吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!