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.

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.

James

share|improve this question
add comment

1 Answer

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

OR

You could do something like this:

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

Working Example/DEMO

enter image description here

share|improve this answer
2  
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
2  
@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
1  
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
1  
Well, looks like we lost it to the crocodiles. –  Devdatta Tengshe Feb 6 at 16:43
show 3 more comments

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.