更改MapLabel谷歌地图实用程序库的不透明度

时间:2013-06-10 15:57:36

标签: google-maps google-maps-api-3

我正在尝试更改为mapLabel的不透明度,但结果是参考中没有opacity属性: http://google-maps-utility-library-v3.googlecode.com/svn/trunk/maplabel/docs/reference.html

1 个答案:

答案 0 :(得分:1)

解决方案:在maplabel.js中添加:

function MapLabel(opt_options) 
{
    ...
    this.set('opacity',1);
    ...
}

并添加另一个:

<MapLabel.prototype.changed = function(prop)
{
    switch (prop) {
    ...     
    case 'opacity':
    return this.drawCanvas_();
    ...
    }
}

还有1个:

MapLabel.prototype.drawCanvas_ = function() 
{
    ...
    ctx.fillStyle = this.get('fontColor');
    ctx.globalAlpha = this.get('opacity');
    ctx.font = this.get('fontSize') + 'px ' + this.get('fontFamily');
    ...
}

如果你想搜索strokeOpacity,这将无法解决......

哦,如果我没有正确地提出实际问题或任何问题,我很抱歉,首次在stackoverflow中提交以发布解决方案。

Placing a MapLabel on top of a Polygon in Google Maps V3

How to change the opacity (alpha, transparency) of an element in a canvas element after it has been drawn?