有没有办法淡出V3 google.maps.Polygon? [英] Is there a way to fade out a V3 google.maps.Polygon?

查看:181
本文介绍了有没有办法淡出V3 google.maps.Polygon?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法淡出V3 google.maps.Polygon?



不是只隐藏/移除标准的Google Maps V3多边形,我想淡化它out。



这可能吗?有没有什么插件呢?

解决方案

以下是我为解决笔画和填充的统一淡出而创建的解决方案,我把它作为一个函数很容易重用。



秒是需要多长时间才会发生淡出和回调,因此一旦完成就可以执行另一个操作。

在我的项目中,我的回调函数从地图中删除了多边形并删除了变量。

  function polygon_fadeout(polygon,seconds,callback){
var
fill =(polygon.fillOpacity * 50)/(seconds * 999),
stroke =(polygon .strokeOpacity * 50)/(seconds * 999),
fadeout = setInterval(function(){
if(polygon.strokeOpacity + polygon.fillOpacity< = 0.0){
clearInterval(fadeout );
polygon.setVisible(false);
if(typeof(callback)=='function')
callback();
返回;
}
polygon.setOptions({$ b $'fillOpacity':Math.max(0,polygon.fillOpacity-fill),
'strokeOpacity':Math.max(0 ,polygon.strokeOpacity-stroke)
});
},50);
}


Is there a way to fade out a V3 google.maps.Polygon?

Instead of just hiding / removing a standard Google Maps V3 polygon I want to fade it out.

Is this possible? Are there any plugins out there?

解决方案

The following is a solution I created to address the uniform fade out of stroke and fill and I made it easily reusable by making it a function.

seconds is how long it will take the fade out to occur and callback so you could do perform another action once it completes.

In my project my callback function removes the polygon from the map and deletes the variable.

function polygon_fadeout(polygon, seconds, callback){
    var
    fill = (polygon.fillOpacity*50)/(seconds*999),
    stroke = (polygon.strokeOpacity*50)/(seconds*999),
    fadeout = setInterval(function(){
        if(polygon.strokeOpacity + polygon.fillOpacity <= 0.0){
            clearInterval(fadeout);
            polygon.setVisible(false);
            if(typeof(callback) == 'function')
                callback();
            return;
        }
        polygon.setOptions({
            'fillOpacity': Math.max(0, polygon.fillOpacity-fill),
            'strokeOpacity': Math.max(0, polygon.strokeOpacity-stroke)
        });
    }, 50);
}

这篇关于有没有办法淡出V3 google.maps.Polygon?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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