Skip to content

Instantly share code, notes, and snippets.

@yellow-sky
Created October 15, 2015 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yellow-sky/ebd6d0dbae76597384c5 to your computer and use it in GitHub Desktop.
Save yellow-sky/ebd6d0dbae76597384c5 to your computer and use it in GitHub Desktop.
handlers
layers = [zapros, zapros2];
var i;
i=2;
var n=0;
var all_datas = [];
var all_bh = [];
var all_data_sources = [];
var keys =[];
for (n=0; n<i; n++) {
layer = layers[n];
data_for_layer = [];
all_datas.push(data_for_layer);
bh_for_layer = new Bloodhound({
datumTokenizer: function (d) {
return Bloodhound.tokenizers.whitespace(d.name);
},
queryTokenizer: Bloodhound.tokenizers.whitespace,
local: data_for_layer,
initialize: false
});
all_bh.push(bh_for_layer);
all_data_sources.push({
displayKey: "name",
source: bh_for_layer
});
key = layer.getSource().on('change', function () {
if (layer.getSource().getState() == 'ready') {
layer.getSource().unByKey(key);
console.log(layer);
layer.getSource().forEachFeature(function (feature) {
data_for_layer.push({'id': feature.getId(), 'name': feature.get('Shifr')})
}
);
bh_for_layer.initialize();
}
});
keys.push(key);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment