2

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

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! – strangeoptics Aug 19 '13 at 14:11
1

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
    });
map.addControl(selector1);

selector2 = new OpenLayers.Control.SelectFeature(facility,{
        onSelect: onFacilitySelect,
        onUnselect: onFacilityUnselect
        //hover:true
    });
map.addControl(selector2);

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. – strangeoptics Aug 20 '13 at 13:15
0

you can use the events property on layer. eg.

Layer1.events.on({"featureselected":function1()});

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, privacy policy and cookie policy

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