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

I am able to identify the selected features on my map using the following line:


I would like to be able to deselect this feature using a standalone function (not an event-handler). I've tried using the functions unselect() and unselectAll() unsuccessfully and can't find any examples of this approach.

I am aware that clicking on the selected object can be used to unselect. In this case I want a programmatic solution.

share|improve this question
It's not quite what I am trying to do but unSelect issues are discussed here: – djq Nov 13 '12 at 18:22
thanks for the suggestions. I have seen these and tried to adapt them for my grid layer. As far as I can tell, every example for selecting features involved creating the features first. I have not (yet) seen a working example where an existing layer is loaded and the user selects features from this layer. I am starting to think that selectFeature only works for vectors that you create on the fly. I hope this is not true or else I am in trouble. ;) – user2378729 May 21 '13 at 20:33
up vote 11 down vote accepted

You can unselect features with unselect and unselectAll methods of SelectFeature control:

selectControl = new OpenLayers.Control.SelectFeature(vectorLayer);

// unselect any specific feature...
// ...or all features

If this doesn't work, there's probably bug in your code.

Here is fiddle:

share|improve this answer
I don't see that in the documentation... but it works! – pakman Dec 4 '14 at 17:38

Openlayers unselecting Objects - various methods

Use the shift key to select multiple features. Use the ctrl key to toggle selection on features one at a time. Note: the "clickout" option has no effect when "hover" is selected

click out to unselect features

share|improve this answer
Sorry, should have added the word programmatic. I want to unselect using a function, not a click. – djq Nov 13 '12 at 18:38

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.