在echart的地图上添加自定义按钮等

  这几天做了个小项目,关于地图的。所以使用echart比较多,记录一下,免得以后忘了。

首先是添加自定义按钮:引用toolbox对象,官方上的写的示例很清楚。下面附上写的代码

option.toolbox={
orient : 'vertical',
right:'3%',
top:'3%',
itemSize:40,
itemGap:25,
feature: {
myTool1: {
show: true,
title: '返回上级',
icon: 'image://../../img/up.png',
onclick: function (){
if(APP_AREA.level != 'province' ){
var url = window.location.pathname;
window.location = url.substring(0, url.lastIndexOf('/') + 1)
+ APP_AREA.parentId;

}
}
},
myTool2: {
show: true,
title: '返回下级',
icon: 'image://../../img/down.png',
onclick: function (){
if (APP_AREA.level != 'county' ) {
var url = window.location.pathname;
window.location = url.substring(0, url.lastIndexOf('/') + 1)
+ APP_AREA.selectAreaId;
}
}
}
}
}

关于icon属性,可以用path,url。不过前面的image好像都要有。这两个按钮是实现返回上级和下级的。

关于选中地图在右边的散点图上高亮该点显示出来:循环遍历一遍,将被选中的id取出来传到散点图中:

changeHigh:function(){
for(var i=0;i<PageObject.Xid.length;i++){
if(PageObject.Xid[i]==APP_AREA.selectAreaId){
var num = i;
}

}
this.myChart.dispatchAction({
type: 'downplay',
seriesIndex:0,
});
this.myChart.dispatchAction({
type: 'highlight',
seriesIndex:0,
seriesName:'乡镇',
dataIndex:num,

});


},

 

posted @ 2016-08-16 16:42  清水寺小和尚他爹  阅读(4703)  评论(1编辑  收藏  举报