使用循环对 Fusion 图层进行排序并更新每个结果



我对javascript和Web开发很陌生。我一直在尝试融合表和谷歌API,并难倒了自己。

我希望遍历一个 Javascript 对象,并突出显示融合层中名称与 javascript 对象中名称匹配的任何多边形。代码如下:

function fillcolour(match){ // ---- match is an array within the javascript object
var limit = 0; // --- currently limiting the responses to 5. There are 126 in each response array and I know within the first 5 there are 3 matches.
 var options = {
      styles : []
    };
var styles = [];
for (x in match) {    //---- getting each name in match. from alerts and console log I know this returns 5 results, three of which should satisfy the requirements below. 
    if(limit < 5){
        PolygonLayer.setOptions({
                query: {
                    select: "shape",
                    from: mapTable,
                    where: "'name' = '" + x + "'"
                }
            });
      options.styles.push({
        polygonOptions: {
          fillColor: "#FFF000",
        }
      });
        PolygonLayer.setOptions(options);
        limit++;
    }
}
};

所以我看到的当前结果是只有一个多边形变成黄色(数组中的最后一个(。

我想看到的是循环中检查的所有可行多边形都变为黄色。我很确定答案就在查询语法中,但我一直在搜索半天,但找不到任何东西。

我想要的可能吗?

感谢您的阅读!

你的函数可能看起来像这样

function fillcolour(match){
    PolygonLayer.setOptions({
        styles: [{
            where: "'name' in ('" + match.join("','") + "')"
            polygonOptions: {
                fillColor: "#FFF000"
            }
        }]          
    })
}

最新更新