map.addEventListener("click",function(e){
if(k<5){
var m1 = new BMap.Marker(new BMap.Point(e.point.lng,e.point.lat));//根据数据点击位置创建一个标注
setMarker.push(m1);
map.addOverlay(m1);
setAddress.push(new BMap.Point(e.point.lng,e.point.lat));
if(k==4){
setAddress.push(new BMap.Point(setAddress[0].lng,setAddress[0].lat));
}
setpolygon.setPath(setAddress);
setpolygon.setFillColor("");
map.addOverlay(setpolygon);
k++;
}else{
alert("电子围栏已经设置成功!");
}
var myGeo = new BMap.Geocoder();
myGeo.getLocation(new BMap.Point(e.point.lng,e.point.lat), function(result){
if(result)
{
var address= document.getElementById("setAddress");
if(address.innerHTML=="")
address.innerHTML=result.address;
else
address.innerHTML=address.innerHTML+","+result.address;
}
})
})