当滤波器特征布局ArcGI带有JavaScript时,如何显示结果计数
我在对象中定义的一个项目中有多个布局:
const layersByYears = [
{ year: 1918, layers: [
{ layerID: "443709212b894e9297888b3194b51100", opacity: 1.0, name: "ORP", featureLayer: null },
{ layerID: "61a605dca69c4aa0ac1b3858ba328fd3", opacity: 1.0, name: "obceSouc", featureLayer: null }
] },
{ year: 1936, layers: [
{ layerID: "a2e007238e304f1ea58005fc69c921e9", opacity: 1.0, name: "ORP", featureLayer: null },
{ layerID: "61a605dca69c4aa0ac1b3858ba328fd3", opacity: 1.0, name: "obceSouc", featureLayer: null }
] },
{ year: 1950, layers: [
{ layerID: "23bcd52310854d6185e5f22a4eca0303", opacity: 1.0, name: "ORP", featureLayer: null },
{ layerID: "61a605dca69c4aa0ac1b3858ba328fd3", opacity: 1.0, name: "obceSouc", featureLayer: null }
] },
{ year: 1981, layers: [
{ layerID: "401e9530ba074936800a8f596fc49d70", opacity: 1.0, name: "ORP", featureLayer: null },
{ layerID: "61a605dca69c4aa0ac1b3858ba328fd3", opacity: 1.0, name: "obceSouc", featureLayer: null }
] },
]
然后,我创建变量来设置所有层:
const createFL = (layer) => {
if(layer.featureLayer !== null && layer.featureLayer !== undefined)
return;
layer.featureLayer = new FeatureLayer({ portalItem: {
id: layer.layerID,
opacity: layer.opacity !== undefined ? layer.opacity : 1.0,
visible: false,
} })
layer.featureLayer.load().then(function() {
$("loadingProgressbar").value = ++loadingProgress.value;
$("loadingProgressbar").max = loadingProgress.max;
if(loadingProgress.max === loadingProgress.value)
$("loadingProgressbar").style.display = "none";
});
}
最后我提供了这样的过滤器:
function doQuery() {
var selModul = document.getElementById("jevSelect");
var attributeName = selModul.options[selModul.selectedIndex].value;
const expressionSign = document.getElementById("signSelect");
var selJev = document.getElementById("jevSelect");
var inputValue = selJev.options[selJev.selectedIndex].text;
let expression;
expression = `${attributeName}${expressionSign.value}'${inputValue}'`;
document.getElementById("printResults").innerHTML = expression;
layersByYears.forEach(layerByYear =>
layerByYear.layers.forEach(layer => {
layer.featureLayer.definitionExpression = expression;
})
)
}
我需要在地图中的点上显示每个过滤器上的结果计数(数字)作为标签。 项目在这里
I have multiple layouts in one project defined in object like this:
const layersByYears = [
{ year: 1918, layers: [
{ layerID: "443709212b894e9297888b3194b51100", opacity: 1.0, name: "ORP", featureLayer: null },
{ layerID: "61a605dca69c4aa0ac1b3858ba328fd3", opacity: 1.0, name: "obceSouc", featureLayer: null }
] },
{ year: 1936, layers: [
{ layerID: "a2e007238e304f1ea58005fc69c921e9", opacity: 1.0, name: "ORP", featureLayer: null },
{ layerID: "61a605dca69c4aa0ac1b3858ba328fd3", opacity: 1.0, name: "obceSouc", featureLayer: null }
] },
{ year: 1950, layers: [
{ layerID: "23bcd52310854d6185e5f22a4eca0303", opacity: 1.0, name: "ORP", featureLayer: null },
{ layerID: "61a605dca69c4aa0ac1b3858ba328fd3", opacity: 1.0, name: "obceSouc", featureLayer: null }
] },
{ year: 1981, layers: [
{ layerID: "401e9530ba074936800a8f596fc49d70", opacity: 1.0, name: "ORP", featureLayer: null },
{ layerID: "61a605dca69c4aa0ac1b3858ba328fd3", opacity: 1.0, name: "obceSouc", featureLayer: null }
] },
]
Then I create variable to setup all layers:
const createFL = (layer) => {
if(layer.featureLayer !== null && layer.featureLayer !== undefined)
return;
layer.featureLayer = new FeatureLayer({ portalItem: {
id: layer.layerID,
opacity: layer.opacity !== undefined ? layer.opacity : 1.0,
visible: false,
} })
layer.featureLayer.load().then(function() {
$("loadingProgressbar").value = ++loadingProgress.value;
$("loadingProgressbar").max = loadingProgress.max;
if(loadingProgress.max === loadingProgress.value)
$("loadingProgressbar").style.display = "none";
});
}
Finally I provide filter like this:
function doQuery() {
var selModul = document.getElementById("jevSelect");
var attributeName = selModul.options[selModul.selectedIndex].value;
const expressionSign = document.getElementById("signSelect");
var selJev = document.getElementById("jevSelect");
var inputValue = selJev.options[selJev.selectedIndex].text;
let expression;
expression = `${attributeName}${expressionSign.value}'${inputValue}'`;
document.getElementById("printResults").innerHTML = expression;
layersByYears.forEach(layerByYear =>
layerByYear.layers.forEach(layer => {
layer.featureLayer.definitionExpression = expression;
})
)
}
What I need is to display count of results (number) on each filter as label on point in map.
Project is here map project - the problem is in year 1936.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您需要符合条件的功能计数,则可以仅使用诸如
QUERYFEATURECOUNT
farmaturelayer
的方法使用计数查询( arcgis js js api-featureLeLayer )。在您的情况下,您可以在结构中添加额外的属性,例如count
,并在每次更改定义表达式时填充它,类似这样,If you want the count of features that complied to the condition, you can use just a count query using for example
queryFeatureCount
method ofFeatureLayer
(ArcGIS JS API - FeatureLayer). In your case you could add an extra property to your structure,count
for example and fill it each time you change the definition expression, something like this,