[OpenLayers-Users] Event "featureunhighlighted" not triggered

Olivier THIERRY olivier.thierry at gmail.com
Wed Mar 17 12:14:05 EDT 2010


Hi,

I have a vector layer with two SelectFeature controls : one is used
for selection, the other is used to show a popup.
It works well except for one case : if I select an element in the
vector, then I move the mouse to this element, the
"featurehighlighted" event is fired, but on mouse out the
"featureunhighlighted" event is not fired !

Here is the piece of code to create the layer :

layer = new OpenLayers.Layer.Vector(
	"Rejets",
	{
		styleMap: styles,
		displayInLayerSwitcher : false,
		rendererOptions: {
		    zIndexing: true
		}
	});
map.addLayer(layer);

Here is the control for selection :

var selectControl = new OpenLayers.Control.SelectFeature(
	layer,
	{
		multiple: true
		, hover: false
		, toggle: true
		, onSelect : function(feature) {
			var rejet = feature.rejet;
			if (rejet != null) {
				if (! rejet.selected) {
					feature.selected = true;
					rejet.select();
				}
			}
		}
		, onUnselect : function(feature) {
			var rejet = feature.rejet;
			rejet.hideTooltip();
			if (rejet != null && rejet.selected) {
				feature.selected = false;
				rejet.unselect();
			}
		}
	});
selectControl.id = "selectRejets";

Here is the control to display popup :

var highlightControl = new OpenLayers.Control.SelectFeature(
	layer,
	{
		multiple: false
		, hover: true
		, highlightOnly: true
		, eventListeners: {
			featurehighlighted : function(e) {
				var rejet = e.feature.rejet;
				if (rejet != null) {
					rejet.showTooltip();
				}
			}
			, featureunhighlighted : function(e) {
				var rejet = e.feature.rejet;
				if (rejet != null) {
					rejet.hideTooltip();
				}
			}
		}
	});
highlightControl.id = "highlightRejets";

And the two controls are activated this way (order has influence on behaviour) :

map.addControl(highlightControl);
map.addControl(selectControl);
highlightControl.activate();
selectControl.activate();

Any idea what I did wrong ? Or could it be a bug (if so, I absolutely
need a way to workaround this problem).

Thanks in advance,

Olivier



More information about the Users mailing list