【问题标题】:uniquerValues - view is required to query stats from layerView" and feature-layer-adapter:insufficient-datauniquerValues - 需要视图才能从 layerView" 和 feature-layer-adapter:insufficient-data 查询统计信息
【发布时间】:2019-06-18 16:03:16
【问题描述】:

我正在尝试使用 ESRI ArcGIS for JavaScript 4.10 中的 uniqueValues 函数。

但是,这条消息失败了:

消息:“需要视图才能从 layerView 查询统计信息”名称: “特征层适配器:数据不足”

我有一个 FeatureLayer 的功能和一个名为 sStatus 的字段。我还有一个 Legend 设置,它与基于此 sStatus 字段的 UniqueValueRenderer 一起工作得很好。

这是我的代码:

uniqueValues({
    layer: layer,
    field: "sStatus"
}).then(function (response) {
    // prints each unique value and the count of features containing that value
    var infos = response.uniqueValueInfos;

    console.log('test');

    infos.forEach(function (info) {

        console.log("Wells : ", info.value, " # of Wells ", info.count);
    });
}).catch(errback);

注意:如果我将字段名称更改为“status”,则控制台中的错误消息会更改:

消息:“未知字段:状态。您只能使用定义的字段 层架构”名称:“唯一值:无效参数”

这表明我的字段 sStatus 是正确的,但我不明白为什么它不能开箱即用。

任何想法为什么会失败?

【问题讨论】:

    标签: count arcgis esri unique-values


    【解决方案1】:

    在我发布问题后,我通过重新阅读uniqueValues 函数documentation 得到了答案。

    首先,信息很明确:它缺少视图。

    uniqueValues 函数的 view 参数不是示例代码的一部分...

    查看查看可选

    当 valueExpression 为 指定。

    所以我必须做的是:

    niqueValues({
        layer: layer,
        field: "sStatus",
        view: mapView
    }).then(function (response) {
        // prints each unique value and the count of features containing that value
        var infos = response.uniqueValueInfos;
    
        console.log('test');
    
        infos.forEach(function (info) {
    
            console.log("Wells : ", info.value, " # of Wells ", info.count);
        });
    }).catch(errback);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-19
      • 1970-01-01
      • 2023-03-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-24
      • 1970-01-01
      相关资源
      最近更新 更多