I would like to have one SelectFeature control for every layer so that I can have different representational behaviour for every layer. Means in one layer I want to highlight the features when the mouse hovers in the next not.

When I do this, only the most upper layer is producing onSelect-Events!

3 Answers 3


This is the example using same SelectFeature control on multiple layers. Unfortunately the configuration on the control should be consistent, for example, if you define the control as hover: true, then features on all layers can be selected by mouse hover. In other words, you cannot do something like hover selection in layer A while click selection in layer B by using a single SelectFeature control. There might be a way to do this job, but I guess it's non-trivial.

  • thx, I got mad trying out all possible configurations without any success! Aug 19, 2013 at 14:11

It is possible to define individual select control for each layer. Then you can use radio buttons to activate control on selected layer and deactivate in others.Eg

selector1 = new OpenLayers.Control.SelectFeature(building,{
        onSelect: onFeatureSelect,
        onUnselect: onFeatureUnselect

selector2 = new OpenLayers.Control.SelectFeature(facility,{
        onSelect: onFacilitySelect,
        onUnselect: onFacilityUnselect

then use radio button to activate and deactivate controls

<input type='radio' id='radFacility' value='Facility Wise' checked='checked' onClick='selector1.deactivate();selector2.activate();' name='toggle' defaultChecked='yes'/><label for='radFacility'>Facility</label>
<input type='radio' id='radBuilding' value='Building Wise' onClick='selector2.deactivate();selector1.activate();' name='toggle'/><label for='radBuilding'>Building</label>
  • This is a good idea but I needed it simultaneously. Aug 20, 2013 at 13:15

you can use the events property on layer. eg.


For hover you will have to use the control, i don't know other way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.