How do I fade out a circle in a Google Map, x seconds after I've added it to the map?

前端 未结 1 1601
清歌不尽
清歌不尽 2020-12-21 23:03

What I basically had in mind is what Google did in this example

Every second I want to add circles at certain coordinates and then slowly fade them out. I already ma

相关标签:
1条回答
  • 2020-12-21 23:12

    To fade them out you need to decrease the opacity of the fill and the stroke until it is 0.0.

    setInterval(fadeCityCircles,1000);
    
    function fadeCityCircles() {
      for (var city in citymap) {
        var fillOpacity = citymap[city].cityCircle.get("fillOpacity");
        fillOpacity -= 0.02;
        if (fillOpacity < 0) fillOpacity =0.0;
        var strokeOpacity = citymap[city].cityCircle.get("strokeOpacity");
        strokeOpacity -= 0.05;
        if (strokeOpacity < 0) strokeOpacity =0.0;
        citymap[city].cityCircle.setOptions({fillOpacity:fillOpacity, strokeOpacity:strokeOpacity});
      }
    }  
    

    example

    0 讨论(0)
提交回复
热议问题