openlayer vector的index变化导致mark图层点击事件无效
1.问题:openlayer vector在注册feature的事件后index增加了导致后加入的mark图层点击事件无效。
2.vector添加SelectFeature代码如下:
var selecthover = new OpenLayers.Control.SelectFeature(
featureVectors,
{
hover: true,
highlightOnly:true
}
);
var select = new OpenLayers.Control.SelectFeature(
featureVectors,
{
clickout: true,
toggle: false,
multiple: false,
hover: false,
toggleKey: “ctrlKey”, // ctrl key removes from selection
multipleKey: “shiftKey”, // shift key adds to selection
box: false
}
);
selecthover.handlers.feature.stopDown=false;
selecthover.handlers.feature.stopDown=false;
select.handlers.feature.stopDown=false;
select.handlers.feature.stopUp=false;
map.addControl(selecthover);
map.addControl(select);
selecthover.activate();
select.activate();
selecthover.events.on({ 。。。
featureVectors.events.on({。。。
3.解决方法:在vector注册完事件后,在后面改变vector的index即可:
$(‘.olLayerDiv’).eq(5).css({‘z-index’:’350′});(我的vector在map中的layerindex为5)
转载自:https://blog.csdn.net/DieForCoding/article/details/80541341