<div>       
    <div class='bdmapscript'></div>
    <div id='bdmap-bugsell' style='height:650px;width:100%;'></div>
</div>

 

<script type='text/javascript'>
    $(document).ready(function(){

        //console.log('{{data|safe}}');

        

        var lbl_style={
　　        //color : "white", //字体颜色
　　        fontSize : "15px",//字体大小 　
　　        backgroundColor :"0.5", //文本标注背景颜色
　　        border :"1", 　
　　        fontWeight :"bold" //字体加粗
        };

        !function(mapInit) {
            var script = document.createElement("script");
            script.type = "text/javascript";
            script.src = "https://api.map.baidu.com/api?v=3.0&ak=ASl2xmUaYpjwdWy3GPBQbpUK&callback=mapinit";
            window['mapinit'] = function() {
                mapInit();
            };            
            $('#bg-modal .bdmapscript').html(script);
        }(function() {     
            map = new BMap.Map('bdmap-bugsell'); 


            //map.addControl(new BMap.MapTypeControl({
            //    mapTypes:[BMAP_NORMAL_MAP, BMAP_SATELLITE_MAP, BMAP_HYBRID_MAP]
            //}));
            //map.addControl(new BMap.NavigationControl());
            //map.enableScrollWheelZoom();
            //map.enableContinuousZoom();
            

            /*
            {% for d in data %}    
                
                var p1 = new BMap.Point({{d.lng_lat.0}}, {{d.lng_lat.1}});
                marker = new BMap.Marker(p1);  // 创建标注
                //var label=new BMap.Label('{{s.sn}}', {offset:new BMap.Size(20,0)});
                //label.setStyle(lbl_style);
                //marker.setLabel(label);                
                map.addOverlay(marker);   

                marker.addEventListener('click', function(){
                    this.openInfoWindow(new BMap.InfoWindow(
                        '<div>仓库编号：{{s.sn}}</div>'+
                        '<div>上报时间：{{s.tm}}</div>'+                        
                        '<div>核准时间：{{s.tm_checked}}</div>'                      
                    ));
                });   
                
                
                for (var i = 0; i < result.length; i++) {
                marker = new AMap.Marker({
                    position: bd_decrypt(eval(result[i].lnglat)),
                    icon: '//os.china315net.com/image/icon_danger2.png',
                })
                marker.content = '序号：<span style="font-weight:bold">' + result[i].code + '</span></br>产品：' + result[i].product +
                    '</br>时间：' + result[i].time + '</br>地址：' + result[i].address +
                    '</br>超出范围：' + result[i].distance/1000+" 公里" + '</br><button onclick="sendmessage(\'' + result[i].code + '\',\'' + result[i].product + '\',\'' + result[i].time + '\',\''
                    + result[i].address + '\')">已发送短信给稽查人员</button>';
                marker.on('click', markerClick);
                marker.setMap(map);
                
            }

            {% endfor %}
            */

            //map.centerAndZoom(new BMap.Point({{center.lng}},{{center.lat}}), {{zoom}});
            //map.enableScrollWheelZoom(); //启用滚轮放大缩小，默认禁用
            //map.enableContinuousZoom(); //启用地图惯性拖拽，默认禁用    

            {% for d in data %}    
                
                var p1 = new BMap.Point({{d.lng}}, {{d.lat}});
                var marker = new BMap.Marker(p1);  // 创建标注
                map.addOverlay(marker);  
                marker.setAnimation(BMAP_ANIMATION_BOUNCE); 
                marker.addEventListener('click', function(){
                    var me=this;
                    var infoWin=new BMap.InfoWindow(
                        '<div>标签号码：{{d.label_code}}</div>'+
                        '<div>标签类别：{{d.package}}</div>'+ 
                        '<div>产品名称：{{d.product}}</div>'+  
                        '<div>扫码地点：{{d.address}}</div>'+
                        '<div>扫码时间：{{d.time}}</div>'+
                        '<div>超出范围：{{d.distance}}公里</div>'                     
                    );
                    me.openInfoWindow(infoWin);
                    me.setAnimation(null);
                    infoWin.addEventListener("close", function () {
                        me.setAnimation(BMAP_ANIMATION_BOUNCE);
                    });    
                });   


            {% endfor %}

            map.centerAndZoom(new BMap.Point(72.541653,53.82061), 5);
            map.enableScrollWheelZoom(); //启用滚轮放大缩小，默认禁用
            map.enableContinuousZoom(); //启用地图惯性拖拽，默认禁用   

        });
        
    });

</script>


