参考: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页面
<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>
手机扫一扫
移动阅读更方便
你可能感兴趣的文章