-
Notifications
You must be signed in to change notification settings - Fork 466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Search Features - search in multiple sources at the same time #1115
Comments
No, but you can create a source collection to concat sources on search (it just need to get features in the source): class sourceCollection extends ol.source.Vector {
constructor(opt) {
opt = opt || {};
super(opt);
this._sources = opt.sources
}
getFeatures() {
var a = [];
this._sources.forEach(s => a = a.concat(s.getFeatures()))
return a;
}
} then you can use it as a source: search.setSource(new sourceCollection ({ sources: [source1,source2] }) |
Thank you, this requires both sources to have the same property to search in right? and if the fields to search in were different between the two sources how could I set them? |
No, you can define a // Search in prop1 or prop2
var search = new ol.control.SearchFeature({
source: vectorSource,
getSearchString: function(f) {
return (f.get('prop1') || '') + ' ' + (f.get('prop2') || '')
}
}); |
Sorry but without defining the |
You have to define your own |
I understood, thank you. search.set('getTitle', function(f) {
var title = 'F' + f.get('FOGLIO') + ' ' + 'P' + f.get('PARTICELLA');
return title;
}); |
getTitle is a function, not a property of the objet. search.getTitle = function(f) {
var title = 'F' + f.get('FOGLIO') + ' ' + 'P' + f.get('PARTICELLA');
return title;
}); |
Many thanks |
Good morning,
search features can be set to search in multiple sources at the same time showing a unique list of results?
I would like to search in multiple simultaneous layers by defining one or more fields to look for.
Thanks
The text was updated successfully, but these errors were encountered: