I want to filter an OpenLayers(2) vector layer based on tags. Therefore, the vector layer has a property column which can be filled by comma-seperated tags like e.g. "culture,food,park", but also only one tag e.g. "food". I want to show all features who has one tag "activated" by respective jquery controlled buttons.
with only one tag per feature it is working with the following code:
tags = ['school','food','park'];activeTags = [];function fillArrayOfFilters() { activeLayers = []; $.each(tags, function(id, tag) { if ($('#' + this).hasClass('active') == true) { activeTags.push(tags); }; }); filters = activeLayers.map(function(tag, id) { return new OpenLayers.Filter.Comparison({ type: OpenLayers.Filter.Comparison.EQUAL_TO, property: "tags", value: tag }); });}function filter() { var filter = new OpenLayers.Filter.Logical({ type: OpenLayers.Filter.Logical.OR, filters: filters }); filterStrategy.setFilter(filter);};I know that there is a LIKE comparison in OpenLayers. But how can i use it in this case? I want something like that:
new OpenLayers.Filter.Comparison({ type: OpenLayers.Filter.Comparison.LIKE, property: "tags", value: *tag* });
أكثر...
with only one tag per feature it is working with the following code:
tags = ['school','food','park'];activeTags = [];function fillArrayOfFilters() { activeLayers = []; $.each(tags, function(id, tag) { if ($('#' + this).hasClass('active') == true) { activeTags.push(tags); }; }); filters = activeLayers.map(function(tag, id) { return new OpenLayers.Filter.Comparison({ type: OpenLayers.Filter.Comparison.EQUAL_TO, property: "tags", value: tag }); });}function filter() { var filter = new OpenLayers.Filter.Logical({ type: OpenLayers.Filter.Logical.OR, filters: filters }); filterStrategy.setFilter(filter);};I know that there is a LIKE comparison in OpenLayers. But how can i use it in this case? I want something like that:
new OpenLayers.Filter.Comparison({ type: OpenLayers.Filter.Comparison.LIKE, property: "tags", value: *tag* });
أكثر...