2

I want to select on map that "res_id = 182" but that is selecting all objects on the map.

var filter = new OpenLayers.Filter.Comparison({
    type: OpenLayers.Filter.Comparison.EQUAL_TO,
    property: "res_id",
    value: "182"
});

var  filterStrategy = new OpenLayers.Strategy.Filter({filter: filter});

var control = new OpenLayers.Control.GetFeature({
    protocol: OpenLayers.Protocol.WFS.fromWMSLayer(mylayer),
    strategies: [new OpenLayers.Strategy.Fixed(),filterStrategy],
    box: true,
    multipleKey: "shiftKey",
    toggleKey: "ctrlKey"
});

I actually want to select an area on map and filter selected items by attribute from combobox.

3

Well, you can try CQL-filters for attribute-based queries on WMS. Look this thread for how to filter features of a wms. Afterwards you may select features from your WFS obtained from this WMS. BTW.: the GetFeature-control is designed for selecting features by mouse rather then by any query. To select a feature you may use the SelectFeature-control. Loop the features within your map and activate the control for the desired one as suggested in this thrad. You may also have a look at this thread if you are to use the WFS-built-in filter abbilities.

  • your answer is great. But I want to select an area on map and filter it by attribute. Should I select all objects from WMS and later apply filter. – barteloma Sep 4 '14 at 10:53
  • You want to select one polygonal feature by an attribute? If this is true, one alternative is to apply the filter later or as I suggested in first sentence to update the CQL itself and passing it by calling mergeNewParams – HimBromBeere Sep 4 '14 at 11:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.