Tell me more ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm using new OpenLayers.Control.DrawFeature to draw polygons and OpenLayers.Control.SelectFeature to select a specific polygon. I'm drawing one polgon and then a smaller polygon on top of the first one.

PolyA is a large polygon(50 x 50) PolyB is a smaller polgon (10 x 10) drawn within (on top of) PolyA

Initially I can select and unselect PolyB correctly. However once I have selected and unselected PolyA, PolyB is now hidden behind it and can no longer be selected. Why is that and what can I do to resolve it? Thanks.

select code (straightforward)

select  = new OpenLayers.Control.SelectFeature(layer,
                {
                    highlightOnly: true,    
                    clickout: true, toggle: true,
                    onSelect: function(feature) {

                    //do stuff  
        }           

                });
share|improve this question
1  
show some code so we know how you are using the OpenLayers.Control.SelectFeature – CaptDragon May 22 '12 at 19:16
Show the "do stuff" code. Especially, are you changing the x, y or z-index of the selected item? – Vadim Aug 21 '12 at 10:28

1 Answer

you can achieve this with selecting multiple features at same time. after this you need to do is that put all features under for loop.

var info = []

select = new OpenLayers.Control.SelectFeature(layer, {
box: true,
multiple: true,
onSelect: function(f){
for (var a = 0; a < f.length; a++){
info.push(f[a].attributes.featureName) // or anything you want
}
}   
});

beside this:

layer.selectedFeatures returns you as a result of all selected features..

i hope it helps you...

share|improve this answer
Thanks but that doesn't address the issue. The issue is why a selected-then-unselected feature(polygon) remains in front of a feature it was originally behind. – pov May 23 '12 at 14:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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