I'm having troubles with a highlight layer which I created on a map dynamically to put the selected feature on the top of all layers, so I can see it despite of a polygon layer which has been set visible on the SelectFeature method. It is working well so long I don't try to unselect it. The functions are like:
var HighlightLayer = new OpenLayers.Layer.Vector('HighlightLayer', {
visibility: false
}
);
function selectedFeaturesSchulenEinzug(event) {
HighlightLayer.addFeatures([event.feature]);
// a try with addFeatures but without event.object works well
//HighlightLayer.addFeatures([OrigVectorLayer.features[0]]);
HighlightLayer.setVisibility(true);
//switch on the polygon layer
PolygLayer.setVisibility(true);
}
function unselectFeatureEinzug() {
// switch off the polygon layer
PolygLayer.setVisibility(false);
// remove the features and switch off the highlight layer
HighlightLayer.removeAllFeatures();
HighlightLayer.setVisibility(false);
}
It looks like the event.feature object makes the trouble when I click out the layer. Maybe it tries to put a new event.feature into the HighlightLayer and simultaneously removeAllFeatures. However, when I clear the unselect function and it contains nothing, I have the same problem: it tries to do something and after a while the message prompts that the script doesn't answer. When I try to make the same with a not dynamic feature (like in the script above in the comment), I don't have any troubles and the unselect method can be executed.
Does anybody has experience with a trouble like that?