openlayers 3 - checking all (visible) layers for crossorigin-parameter and return a variable depending on it -


i'm trying receive variable after checked layers of map on crossorigin-property (if given).

in fact want set variable printposs=true/false.

as one visible layer doesnt have proper crossorigin-value variable should become possible=true , function/foreach-loop can quit, returning value "outside"

thats got alreay poor js-knowledge. seems variable keeps value of last processed layer.

jsfiddle here: http://jsfiddle.net/wa5g90xb/3/ (i added browser console-logging)

map.getlayers().foreach(function (layer, idx, a) { if (layer instanceof ol.layer.group) {     layer.getlayers().foreach(function (sublayer, jdx, b) {         var origin = sublayer.getsource()['crossorigin'];         var visible = sublayer.getvisible();         var title = sublayer.get('title');          if (visible === true && origin == 'anonymous') {         printposs=true;          } else if (visible == false) {             printposs = true;          } else {             printposs = false;              //return printposs; can abort here 1 visible layer doesnt have crossorigin         }          return printposs;     });     console.log('outer return:' + printposs + ' - seems value of last "processed" layer returned') } 

});


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -