Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am working on a project that uses openlayers to display a WFS layer(GeoJSON format), I have no problem reading the GeoJSON and display features, but I want to select a feature programmatically, for example, there is a table displaying all the features attributes, when I click a row from the table, I want to select or highlight a specific feature on the map using the ID(or other properties) in that row.

How can I do that?

Thanks

share|improve this question

1 Answer

up vote 1 down vote accepted

First, look up your feature:

myFeature=myVectorLayer.getFeaturesByAttribute("myAttribute","myValue")[0]

Then call .select(myFeature) on your selectControl.

share|improve this answer
this is it, thank you so much!! – TerryLi 18 hours ago

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.