javascript 谷歌地图:透明多边形
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18062396/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Google Maps: Transparent Polygons
提问by Stanley Cup Phil
I have a map that will contain a group of colored polygons. There are times I want to change the fill color of each poly from whatever it is to transparent. I have the following code:
我有一张包含一组彩色多边形的地图。有时我想将每个多边形的填充颜色从任何颜色更改为透明。我有以下代码:
polys[x].setOptions({
fillColor: "#FFFFFF",
fillOpacity: .01, //This changes throughout the program
strokeColor: '#000000',
});
How can I set the fillColor to transparent? Is there a specific hex value?
如何将fillColor设置为透明?是否有特定的十六进制值?
回答by geocodezip
The google.maps.PolygonOptions.fillColoris just that, a color, there is no "transparent" color, that is an Opacity value (0.0 is fully transparent, 1.0 if fully opaque).
所述google.maps.PolygonOptions.fillColor就是这样,颜色,没有“透明的”颜色,即不透明度值(0.0是完全透明的,如果1.0完全不透明)。
fillColor | string | The fill color. All CSS3 colors are supported except for extended named colors.
fillOpacity | number | The fill opacity between 0.0 and 1.0
Update: 0.0 seems to work now for transparent Polygons (jsfiddle)
更新:0.0 现在似乎适用于透明多边形(jsfiddle)