赵国亮的博客

PHP JS LINUX 高性能网站开发

导航

百度地图api 3D图层添加 代码

//设置3D图层
    tileLayer = new BMap.TileLayer({isTransparentPng: true});
    tileLayer.getTilesUrl = function(tileCoord, zoom) {
     
        if(zoom==19)
        {

            //alert('您好!你是非vip会员,不能查看大图!');
            //map.setZoom(18);

            var x = tileCoord.x-103632;
            var y = 34183-tileCoord.y;
            
        }
        
        else if(zoom==18)
        {
            var x = tileCoord.x-51816;
            var y = 17091-tileCoord.y;
            
        }
        
        else if(zoom==17)
        {
            var x = tileCoord.x-25908;
            var y = 8545-tileCoord.y;
            
        }
        
     
        else if(zoom==16)
        {
            var x = tileCoord.x-12954;
            var y = 4272-tileCoord.y;
            
        }
    
    var url= '/statics/mapdata/tiles/' + zoom + '/' + x + ',' + y + '.png';
  
 


    
        //异步检测是否存在图片文件
        var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        xmlhttp.open("GET",url,false);
        xmlhttp.send();
        if(xmlhttp.readyState==4){  

            if(xmlhttp.status==200)
                return url;
            else if(xmlhttp.status==404)
                return '/statics/mapdata/tiles/error.png';
        }
        


     
    }
    

 

posted on 2012-12-06 10:19  赵国亮的博客  阅读(728)  评论(0编辑  收藏  举报

123