Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Openlayers 3 检查crossorigin参数的所有(可见)图层,并根据其返回变量_Openlayers 3 - Fatal编程技术网

Openlayers 3 检查crossorigin参数的所有(可见)图层,并根据其返回变量

Openlayers 3 检查crossorigin参数的所有(可见)图层,并根据其返回变量,openlayers-3,Openlayers 3,在检查了地图的图层的crossOrigin属性(如果给定)后,我试图接收一个变量 事实上,我想设置变量printposs=true/false 只要一个可见层没有正确的交叉原点值,变量就应该变为可能=真,函数/foreach循环可以退出,返回值“外部” 这就是我的知识贫乏所得到的。但变量似乎总是保持最后处理层的值 JSFIDLE here:(我添加了浏览器控制台日志) })) 当然,您必须在循环交互开始时将变量设置为其初始值(undefined)。 map.getLayers().forEach

在检查了地图的图层的crossOrigin属性(如果给定)后,我试图接收一个变量

事实上,我想设置变量printposs=true/false

只要一个可见层没有正确的交叉原点值,变量就应该变为可能=真,函数/foreach循环可以退出,返回值“外部”

这就是我的知识贫乏所得到的。但变量似乎总是保持最后处理层的值

JSFIDLE here:(我添加了浏览器控制台日志)


}))

当然,您必须在循环交互开始时将变量设置为其初始值(
undefined
)。
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 as soon as one visible layer doesnt have Crossorigin
        }

        return printposs;
    });
    console.log('outer return:' + printposs + ' - It seems always the value of the last "processed" layer is returned')
}