gpt4 book ai didi

javascript - OpenLayers 比较过滤器/对象属性

转载 作者:行者123 更新时间:2023-11-30 13:26:17 25 4
gpt4 key购买 nike

是否有可能/是否有解决方法来比较 OpenLayers.Filter.Comparison 中的二级属性?

feature.attributes/context 是某事。喜欢:

{'foo': 'bar', 'baz': {'lorem': 'ipsum', 'dolor': 'sit'}, 'amet': 1337}

规则看起来像这样:

var rule = new OpenLayers.Rule({
filter: new OpenLayers.Filter.Comparison({
type: '==',
property: 'baz.dolor', /* <- this does not work! */
value: 'sit'
}),
symbolizer: {
graphic: true,
graphicZIndex: 100,
backgroundGraphicZIndex: 500,
externalGraphic: OpenLayers.Util.getImagesLocation() + 'foo.png',
graphicHeight: 22,
graphicWidth: 22,
graphicTitle: '${display_name}',
strokeColor: '#FF0000'
}
});

最佳答案

您可以使用 OpenLayers.Filter.Function 过滤器:

var filter = new OpenLayers.Filter.Function({
evaluate: function(attributes) {
return attributes.baz.dolor === 'sit';
}
});

(未经测试的例子)

关于javascript - OpenLayers 比较过滤器/对象属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8323576/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com