热力图heatmap使用

参考:https://www.cnblogs.com/julinhuitianxia/p/7755246.html

1.首先到echarts官网下载应用实例:http://echarts.baidu.com/examples/editor.html?c=heatmap-bmap

2.在A页面中用iframe标签进行跳转(使用该方法的原因:如果你的主页面有应用到其他版本的echarts或jQuery话可能会因为echarts或jQuery版本问题一直报错,如果单纯仅仅使用热力图的话可以直接使用)

3.heatmap-bmap.html页面 

<!DOCTYPE html>
<html style="height: 100%">
   <head>
       <meta charset="utf-8">
   </head>
   <body style="height: 100%; margin: 0">
       <div id="container" style="height: 100%"></div>
      <!--引用jQuery-->
      <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>

       <script type="text/javascript" src="../../../script/plugin/jquery/jquery.cookie.js"></script>
       <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/echarts.min.js"></script>
       <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts-gl/echarts-gl.min.js"></script>
       <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts-stat/ecStat.min.js"></script>
       <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/extension/dataTool.min.js"></script>
       <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/map/js/china.js"></script>
       <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/map/js/world.js"></script>
       <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=ZUONbpqGBsYGXNIYHicvbAbM"></script>
       <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/extension/bmap.min.js"></script>
       <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/simplex.js"></script>

       <script type="text/javascript">
           var dom = document.getElementById("container");
            var myChart = echarts.init(dom);
            var app = {};
            option = null;
            var lon ='';
            var lat ='';
            app.title = '热力图与百度地图扩展';
            $.ajax({
                type: 'POST',
                url: '../../../baseinfo/demoCounty/queryHotMapData.do',
                data: {'county':$.cookie('defaultCounty')},
                cache: false,
                success: function (da) {
                    var arr = da.opInfo.hotMapData;
                    var data =[];
                    lon=arr[0].LON;
                    lat=arr[0].LAT;
                    for(var i=0;i<arr.length;i++){
                        var coord=[]
                        coord.push(arr[i].LON);coord.push(arr[i].LAT);coord.push(1) ;
                        data.push(coord)
                    }
                    myChart.setOption(option = {
                        animation: false,
                        bmap: {
                            center: [lon, lat],
                            zoom: 10,   //地图比例尺,调节地图初始化时候的大小
                            roam: true
                        },
                        visualMap: {
                            show: false,
                            top: 'top',
                            min: 0,
                            max: 5,
                            seriesIndex: 0,
                            calculable: true,
                            inRange: {
                                color: ['blue', 'blue', 'green', 'yellow', 'red']
                            }
                        },
                        series: [{
                            type: 'heatmap',
                            coordinateSystem: 'bmap',
                            data: data,
                            pointSize: 5,
                            blurSize: 6
                        }]
                    });
                    if (!app.inNode) {
                        // 添加百度地图插件
                        var bmap = myChart.getModel().getComponent('bmap').getBMap();
                        bmap.addControl(new BMap.MapTypeControl());
                    }
                },
                dataType: "json",
                error: function (er) {
                }
            });

            if (option && typeof option === "object") {
                myChart.setOption(option, true);
            }
       </script>
   </body>
</html>

 

转载于:https://www.cnblogs.com/ysgcs/p/8569070.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值