Javascript 如何在鼠标悬停时突出显示而不清除选择控件
在OpenLayers中,当光标在向量层上移动时,我试图突出显示向量层的特征。我能做到 我还试图使功能可选,并有一个弹出框时,他们被点击。 这也行得通 我不能让他们同时工作。鼠标悬停选择似乎位于弹出选择的上方。我的代码是基于,但有一些不同。有人知道为什么悬停选择和选择不能共存吗Javascript 如何在鼠标悬停时突出显示而不清除选择控件,javascript,select,openlayers,mouseover,highlight,Javascript,Select,Openlayers,Mouseover,Highlight,在OpenLayers中,当光标在向量层上移动时,我试图突出显示向量层的特征。我能做到 我还试图使功能可选,并有一个弹出框时,他们被点击。 这也行得通 我不能让他们同时工作。鼠标悬停选择似乎位于弹出选择的上方。我的代码是基于,但有一些不同。有人知道为什么悬停选择和选择不能共存吗 select = new OpenLayers.Control.SelectFeature(vector_Layer, {clickout: true}); vector_Layer.events.on
select = new OpenLayers.Control.SelectFeature(vector_Layer, {clickout: true});
vector_Layer.events.on({
"featureselected": onFeatureSelect,
"featureunselected": onFeatureUnselect
});
map.addControl(select);
select.activate();
select.handlers['feature'].stopDown = false;
select.handlers['feature'].stopUp = false;
//REMOVED AS OVERRODE SELECT selectHover = new OpenLayers.Control.SelectFeature(vector_Layer, {hover: true});
function onPopupClose(event) {
select.unselectAll();
}
function onFeatureSelect(event) {
var feature = event.feature;
var content = "<p>"+feature.attributes.SHEET.value + "</p>" + feature.attributes.description;
if (content.search("<script") != -1) {
content = "Content contained Javascript! Escaped content below.<br>" + content.replace(/</g, "<");
}
popup = new OpenLayers.Popup.FramedCloud("chicken",
feature.geometry.getBounds().getCenterLonLat(),
new OpenLayers.Size(100,100),
content,
null, true, onPopupClose);
feature.popup = popup;
map.addPopup(popup);
}
function onFeatureUnselect(event) {
var feature = event.feature;
if(feature.popup) {
map.removePopup(feature.popup);
feature.popup.destroy();
delete feature.popup;
}
}
var info = function(evt) {
OpenLayers.Console.log(evt.type, evt.feature.id);
};
//REMOVED OF OVERODE SELECT var highlight = new OpenLayers.Control.SelectFeature(vector_Layer, {
// hover: true,
// highlightOnly: true,
// renderIntent: "temporary",
// eventListeners: {
// beforefeaturehighlighted: info ,
// featurehighlighted: info ,
// featureunhighlighted: info
// }
// });
//map.addControl(highlight);
//highlight.activate();
var vector_style_d = new OpenLayers.Style({
'fillColor': '#669933',
'fillOpacity': .5,
'strokeColor': '#aaee77',
'strokeWidth': 3,
'cursor': 'pointer'
})
var vector_style_s = new OpenLayers.Style({
'fillColor': '#FE2E2E',
'fillOpacity': .8,
'strokeColor': '#aaee47',
'strokeWidth': 4,
'cursor': 'pointer'
})
var vector_style_t = new OpenLayers.Style({
'fillColor': '#FE2E2E',
'fillOpacity': .8,
'strokeColor': '#aaee47',
'strokeWidth': 3,
'cursor': 'pointer'
})
var vector_style_map = new OpenLayers.StyleMap({
'default': vector_style_d,
'select': vector_style_s,
'temporary': vector_style_t,
});
vector_Layer.styleMap = vector_style_map;
select=newopenlayers.Control.SelectFeature(向量层,{clickout:true});
向量_Layer.events.on({
“featureselected”:在FeatureSelect上,
“featureunselected”:onFeatureUnselect
});
map.addControl(选择);
选择。激活();
select.handlers['feature'];
select.handlers['feature'].stoup=false;
//删除为OVERRODE SELECT selectHover=new OpenLayers.Control.SelectFeature(vector_Layer,{hover:true});
函数onPopupClose(事件){
select.unselectAll();
}
功能onFeatureSelect(事件){
var-feature=event.feature;
var content=“”+feature.attributes.SHEET.value+”“+feature.attributes.description;
if(content.search(“我也有同样的问题,但我正在查看OL页面()中提供的示例)
对我来说,诀窍是改变调用这两个控件的构造函数的顺序(应该先悬停,然后选择)
干杯