AGSFeature.attributes ArcGIS Runtime 100 现在在其字典中提供参数

AGSFeature.attributes of ArcGIS Runtime 100 now giving parameters in its dictionary

我正在发送几何查询以显示在地图上选择的要素并获取所选要素。 两者都工作正常,但是当我检查一个特征的属性字典时,它只包含 5 key/value 对,但 android 中的相同函数返回 10 key/value 对。

我正在这样查询

let query = AGSQueryParameters()

    if let selectionGraphicGeometry = selectionGraphic?.geometry {
        let geometry = AGSGeometryEngine.simplifyGeometry(selectionGraphicGeometry)

        query.geometry = geometry
    }

        selectableLayer?.selectFeatures(withQuery: query, mode: AGSSelectionMode.add, completion: { (result, error) in
        if let features = result?.featureEnumerator().allObjects {
            for feature in features {
                let keys = feature.attributes.allKeys
            }
        }

    }

我不知道我哪里做错了

在 Version 100 Runtime 中,为了提高效率,我们采用了稍微不同的方法。

默认情况下,功能将仅包含渲染和编辑所需的最少字段集。当您制作 selection 时,您正在使用这些功能,因此您会看到较小的字段集。

如果您需要 selected 功能的所有字段,您实际上应该对 AGSServiceFeatureTable 和 select 基于此的功能执行查询。

像这样:

let table = selectableLayer.featureTable as? AGSServiceFeatureTable
table?.queryFeatures(with: query, queryFeatureFields: .loadAll) { (result, error) in
    guard error == nil else {
        print("Error selecting features: \(error!.localizedDescription)")
        return
    }

    guard let features = result?.featureEnumerator().allObjects else {
        return
    }

    selectableLayer.select(features)

    for feature in features {
        let keys = feature.attributes.allKeys
        print(keys)
    }
}

奇怪的是,您说 Android 上返回的字段数与 iOS 上返回的字段数不同。您确定 Android 应用使用相同的渲染器显示相同的图层吗?

还有一点:您最好使用 Esri Community (GeoNet). The ArcGIS Runtime SDK for iOS Forum can be found here。如果您在 iOS 和 Android 上看到具有相同图层和渲染器的不同数量的字段,请在那里做 post 一个问题。

希望对您有所帮助!

P.S。您可能想知道两件相关的事情。

  1. AGSArcGISFeature 个实例现在 Loadable. So if you have an individual feature and you want to get all the fields for it from the source service,您可以调用 load(completion:)。或者您可以将 [AGSArcGISFeature] 数组传递给 ASGLoadObjects() 辅助函数。但是,该函数将为每个功能发出单独的网络请求,因此如果您的数组不小,可能会导致糟糕的用户体验。
  2. 您可以将 AGSServiceFeatureTable.featureRequestMode 设置为 .manualCache。然后您需要调用 populateFromServiceWithParameters() 以在本地加载您需要的精确数据(并且当您平移和缩放地图时,您将需要手动管理此缓存)。有关详细信息,请参阅 here