日期:2014-05-16  浏览次数:20509 次

如何实现自定义区域闪烁效果
自定义的边框无法闪烁,有没有能使之闪烁或使整个自定义背景闪烁的方法?
HTML code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>北京市海淀区地图信息</title>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.1&services=true"></script>
</head>
<body>

<div style="float:left;">
    <input type="button" id="plane" name="plane" value="平面" onclick="plane()" />
</div>
<div style="float:left">
    <textarea id="infor" cols="50" rows="4"></textarea>
</div><br />

<div style="float:none;width:1200px;height:530px;border:1px solid gray" id="container"></div>
<script type="text/javascript">
var textObj = document.getElementById("infor");
var city = "北京市";
var companyInfo = "中网通讯网络有限公司  联系电话:010-62341300。";
var currentState = true;

var map = new BMap.Map("container");
var point = new BMap.Point(116.371481, 39.996095);
map.centerAndZoom(point, 17);
window.load=plane();
//控件
function addControls(mapObj){
    mapObj.enableScrollWheelZoom();                  // 启用滚轮放大缩小。
    mapObj.enableKeyboard();                         // 启用键盘操作。

    //添加多个控件
    mapObj.addControl(new BMap.NavigationControl());
    mapObj.addControl(new BMap.ScaleControl());
    mapObj.addControl(new BMap.OverviewMapControl());

    // 添加实时路况控件
    mapObj.addControl(new BMap.TrafficControl());
}

//标注
function markInfor(map,point){
    var marker = new BMap.Marker(point);
    var opts = {
      width : 250,     // 信息窗口宽度
      height: 100,     // 信息窗口高度
      title : "中网"  // 信息窗口标题
    }
    var infoWindow = new BMap.InfoWindow(companyInfo, opts);  // 创建信息窗口对象
    map.addOverlay(marker);
    marker.addEventListener("mouseover", function(){          
       this.openInfoWindow(infoWindow); 
    });
}

//平面显示
function plane(){
    var map = new BMap.Map("container");
    var point = new BMap.Point(116.371541, 39.996095);
    var pStart = new BMap.Point(116.371423, 39.996309);
    var pEnd = new BMap.Point(116.371648, 39.995947);
    map.setCurrentCity("北京"); 
    map.centerAndZoom(point, 19);
    markInfor(map,point); //标注
    addControls(map);     //控件
    var polygon = new BMap.Polygon([
      new BMap.Point(pStart.lng,pStart.lat),
      new BMap.Point(pEnd.lng,pStart.lat),
      new BMap.Point(pEnd.lng,pEnd.lat),
      new BMap.Point(pStart.lng,pEnd.lat)
    ], {strokeColor:"blue", strokeWeight:3, strokeOpacity:0.5});
    map.addOverlay(polygon);
    polygon.addEventListener("mouseover",function(){
        polygon.setStrokeColor("red");
        map.panTo(point);
        textObj.innerHTML = companyInfo;
    });
    polygon.addEventListener("mouseout",function(){
        polygon.setStrokeColor("blue");
        textObj.innerHTML = "";
    });    
    //alert("obj_color-->>"+polygon._config.strokeColor);  //自定义区域边框颜色
    
    function blinkit(polygon){
        intrvl=0;
        for(nTimes=0;nTimes<30;nTimes++)
        {
            intrvl += 500;
            setTimeout(function(){polygon._config.strokeColor='yellow';},intrvl);
            intrvl += 500;
            setTimeout(function(){polygon._config.strokeColor='red';},intrvl);
          }
    }
    setTimeout(blinkit(polygon),500);
    //setTimeout("blinkit("+polygon+")",500);
}

</script>