Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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]
        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
check this link out:… – Glenn Plas Nov 10 '12 at 2:40
Thanks @GlennPlas - that link pointed out that selection can be done using[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
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:[i]); 

when selectFeature is defined as a control.

share|improve this answer

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


i hope it helps you...

share|improve this answer

Your Answer


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.