百度地marker点加波纹动画效果

<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
	<style type="text/css">
	body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
       .css_animation{  
        height:60px;  
        width:60px;  
        border-radius: 30px;  
        background: rgba(250, 0, 0, 0.9);  
        transform: scale(0);  
        animation: myfirst 4s;  
        animation-iteration-count: infinite;  
    }  
  
    @keyframes myfirst{  
        to{  
            transform: scale(0.6);  
            background: rgba(0, 0, 0, 0);  
        }  
    } 
	</style>
	<script type="text/javascript" src="//api.map.baidu.com/api?v=2.0&ak=您的密钥"></script>
	<title>地图展示</title>
</head>
<body>
   <div id="c_test" class="css_animation" style="display:none;"> </div>

	<div id="allmap"></div>
</body>
</html>
<script type="text/javascript">
  function ComplexCustomOverlay(point , marker){
	 
		this._point = point;
		this._marker = marker;
	}
 
	ComplexCustomOverlay.prototype = new BMap.Overlay();
	ComplexCustomOverlay.prototype.initialize = function(map){
		this._map = map;
		var div = this._div = document.createElement("div");
		div.style.position = "absolute";  
		var arrow = this._arrow = document.createElement("div");
   
		arrow.style.position = "absolute"; 
		arrow.style.overflow = "hidden";
		div.appendChild(arrow);
		arrow.className="css_animation";  
    
		 if(this._marker ){
			map.addOverlay(this._marker );
		} 

		map.getPanes().labelPane.appendChild(div);
    
		return div;
	}
	ComplexCustomOverlay.prototype.draw = function(){
		var map = this._map;
		var pixel = map.pointToOverlayPixel(this._point);
		this._div.style.left = pixel.x - 30 + "px";
		this._div.style.top  = pixel.y - 30 + "px";
		 
		
	}
	
	ComplexCustomOverlay.prototype.setPosition = function(point) {
		this._point = point ;
		this.draw();
		if(this._marker)
			this._marker.setPosition(this._point);
		  
	}
	
	ComplexCustomOverlay.prototype.getPosition = function() {
		return this._point ; 
		  
	}
    
	// 百度地图API功能
	var map = new BMap.Map("allmap");    // 创建Map实例
	map.centerAndZoom(new BMap.Point(116.404, 39.915), 11);  // 初始化地图,设置中心点坐标和地图级别
	//添加地图类型控件
	map.addControl(new BMap.MapTypeControl({
		mapTypes:[
            BMAP_NORMAL_MAP,
            BMAP_HYBRID_MAP
        ]}));	  
	map.setCurrentCity("北京");          // 设置地图显示的城市 此项是必须设置的
	map.enableScrollWheelZoom(true);     //开启鼠标滚轮缩放
    var m1 = addMarker(116.404,39.915);
    map.addOverlay(m1);

    var m2 = addMarker(116.434,39.915);
    map.addOverlay(m2);
  
    var m3 = addMarker(116.404,39.955);
    map.addOverlay(m3);
  
    var m4 = addMarker(116.474,39.911);
    map.addOverlay(m4);
    function addMarker(_lon, _lat) {
		var point = new BMap.Point(_lon, _lat);
 
		var size = new BMap.Size(48, 48);
 
		var marker = new BMap.Marker(point, {
            icon: new BMap.Symbol(BMap_Symbol_SHAPE_CIRCLE, {
            scale: 6,
              rotation: 0,
              fillColor: "#f8081d",
              fillOpacity: 1,
              strokeColor: "#ff0016",
              strokeOpacity: 0.1,
              strokeWeight: 15
            })
         }); 
		 var plex = new ComplexCustomOverlay(point, marker); // 创建标
		 return plex;
	}
  
</script>

效果

源码下载地址:https://github.com/wanghongzheng/baidumap

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值