Created
October 15, 2015 13:40
-
-
Save yellow-sky/ebd6d0dbae76597384c5 to your computer and use it in GitHub Desktop.
handlers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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