百度地图api 用闭包实现对多个覆盖物事件的保存

时间:2021-05-24 19:32:42
  //闭包实现保留面的事件 开始 =======================================================
function qiuxu(){

var qiuxu_id = this_id;
var qiuxu_zhongxin = this_zhongxin;
var qiuxu_dian = this_dian;
var qiuxu_mingcheng = this_mingcheng;


//鼠标经过面的时候
xx_mian[qiuxu_id].addEventListener("mouseover", function(){
xx_mian[qiuxu_id].setFillOpacity(
0.1);
xx_mian[qiuxu_id].setStrokeOpacity(
1);
//中心坐标显示
//marker[qiuxu_id].show();
});


//鼠标在面上移动的时候
xx_mian[qiuxu_id].addEventListener("mousemove", function(){

var tishi_mingcheng = document.getElementById('tishi_mingcheng'); //将要弹出的层
tishi_mingcheng.style.display="block";
tishi_mingcheng.style.left
=window.event.clientX+20;
tishi_mingcheng.style.top
=window.event.clientY;
tishi_mingcheng.style.position
="absolute";
document.getElementById(
'tishi_mingcheng2').innerHTML = qiuxu_mingcheng;

});

//鼠标离开面的时候
xx_mian[qiuxu_id].addEventListener("mouseout", function(){

xx_mian[qiuxu_id].setFillOpacity(
0.01);
xx_mian[qiuxu_id].setStrokeOpacity(
0.01);
marker[qiuxu_id].hide();
var tishi_mingcheng = document.getElementById('tishi_mingcheng'); //将要弹出的层
tishi_mingcheng.style.display="none";

});