1.从后台获取数据后,循环时对每个要素进行属性设置;
hexfeature.setAttributes( {"XCoord":111,"YCoord":222,"Plant":"Mesa Mint"});
2.将要素添加到要素图层上,当点击要素图层时,响应点击事件,点击后弹出弹出框;
var showInfowindow= hexlayer.on("click",addInfo);
function addInfo(evt){
var attributes=evt.graphic.attributes;
map.infoWindow.setTitle("Coordinates");
map.infoWindow.setContent(
'<div style="background-color:lightblue;color:white;">' +
"XCoord : " +attributes.XCoord +'</div>'
);
map.infoWindow.show(evt.mapPoint, map.getInfoWindowAnchor(evt.screenPoint));
};
3.隐藏弹出框;
map.infoWindow.hide();
4.解除弹出框绑定事件;
showInfowindow.remove();