//仅供参考(与layui前端框架配合使用)
$(function(){
createModelAllLayer();
wbgraphicsOnMouseOut();
});
/**
* 用于轨迹鼠标悬浮事件
*/
var wbnpTtNum,wbnpTtArray;
function wbgraphicsOnMouseOut(){
var modelAllLayer=map.getLayer("modelAllLayer");
var wbnplayerConnect=dojo.connect(modelAllLayer, "onMouseMove", function(evt) {
var g = evt.graphic;
if(wbnpTtNum==g.attributes.id){
if(tipsClose<=0){
//轨迹鼠标悬浮展示层【layui】
showTrajectoryTips(wbnpTtArray,evt.target);
}
return true;
}
var id=g.attributes.id;
//遍历图层获取需要展示的数组数据
wbnpTtArray=querywbnpDates(id);
wbnpTtNum=id;//将序号传给wbnpTtNum
//轨迹鼠标悬浮展示层【layui】
showTrajectoryTips(wbnpTtArray,evt.target);
});
//dojo.disconnect(wbnplayerConnect);//移除图层的监听事件
}
/**
* 轨迹鼠标悬浮之获取graphic信息(包含重复叠加的graphic)
*/
function querywbnpDates(id){
var graphics=modelAllLayer.graphics;
var array=new Array(),a=0;
for(var i=0;i<graphics.length;i++){
var gid=graphics[i].attributes.id;
if(id==gid){
array[a]={
"name":graphics[i].attributes.wbname
};
a++;
}
}
return array;
}
var tipsClose;
/**
* 轨迹鼠标悬浮之展示层【layui】
*/
function showTrajectoryTips(array,target){
var str="<div>";
for(var a=0;a<array.length;a++){
str+="<p>"+array[a].name+"</p>";
}
str+="</div>";
tipsClose=layer.tips(str, target, {
tips: [1, '#3595CC'],
area: ['350px', 'auto'],
time: 0//tips一直存在
});
}
/**
* 创建图层和鼠标移出事件
*/
function createModelAllLayer(){
//创建一键搜索图层
var layerid="modelAllLayer";
modelAllLayer = new esri.layers.GraphicsLayer();
modelAllLayer.id=layerid;
map.addLayer(modelAllLayer);
//鼠标移出事件,用于鼠标悬浮tips展示
dojo.connect(modelAllLayer, "onMouseOut", function(evt) {
if(tipsClose && tipsClose>0){
layer.close(tipsClose);
tipsClose=0;
}
});
}