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'm working with Openlayers and overlaying a geojson file representing species type over OSM. I have an HTML form that allows users to select a species type and I then need to filter the geojson layer based on the selection. I then want the map to redraw, displaying only the filtered features.

I've tried CQL and messed around with styling but I'm not getting very far. Does anyone have any experience of doing this?

Thanks in advance.


share|improve this question

The OpenLayers.Format.GeoJSON read operation takes in a filter function see documentation


You could do something like this:

if (html.checked == true) { = "block";
} else { = "none";

Working Example/DEMO

enter image description here

share|improve this answer
I was with you on the Cat and Alligator, but you lost me with the elephant drawing...I'm just not seeing it. :-D – Vadim Mar 29 '12 at 17:05
@Vadim : LOL. It's only the profile of its head (ear and trunk) and the trunk is pointed at the cat. It's a work of art. And yes these animals are to scale. ;) – CaptDragon Mar 29 '12 at 17:08
thanks for your help @CaptDragon, really appreciate it. I'll give it a try. I presume you aren't from West Africa? High crocodile mortality rates.... – James Lewis Mar 30 '12 at 9:21
Yes, high mortality rates from the same Croc. – CaptDragon Mar 30 '12 at 13:10
Well, looks like we lost it to the crocodiles. – Devdatta Tengshe Feb 6 '14 at 16:43

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.