Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Using a polygon id, I want to highlight a polygon, while the mouse is outside of the map area. I can identify the polygon using the following approach:

x = 53;
for(i=0; i<vector_layer.features.length; i++){
        y = vector_layer.features[i].attributes.id
        if(x == y){
            vector_layer.features[i].style = ??
        }           
}

However, I can't figure out how to highlight the polygon even though I know which one it is. I have previously defined a style for when the mouse hovers over the polygon and it is selected, but I don't know how to apply this style to the chosen polygon.

share|improve this question
    
how are you planning to select the polygon ID ? –  Glenn Plas Nov 9 '12 at 22:53
    
In this case, I know what the polygon id is through user selection, outside of the map. –  djq Nov 10 '12 at 0:33
2  
check this link out: stackoverflow.com/questions/8832029/… –  Glenn Plas Nov 10 '12 at 2:40
1  
Thanks @GlennPlas - that link pointed out that selection can be done using selectFeature.select(this.vlayer.features[i]); when selectFeature is defined as a control. Not sure if you can move your comment to answer, but I could mark as the answer if so. –  djq Nov 12 '12 at 22:30
    
It will be a short answer, but It's good to be able to close a question, GIS has a lower answer rate than SO. –  Glenn Plas Nov 13 '12 at 7:56
add comment

2 Answers

up vote 2 down vote accepted

The possible solution to this problem can be extracted from this SO entry. That link points out that selection can be done using:

selectFeature.select(this.vlayer.features[i]); 

when selectFeature is defined as a control.

share|improve this answer
add comment

There is no problem with your code but you have to redraw your layer after changing its style. Put this line into your loop:

vector_layer.redraw();

i hope it helps you...

share|improve this answer
add comment

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.