无法从 ArcGIS Online 要素服务查询要素属性

Cannot Query Feature Attributes from ArcGIS Online Feature Service

我在 ArcGIS Online 上创建了一个要素服务,其中包含大约 2000 个要素。每个要素都有四个字段:名称、纬度、经度和布尔验证字段 (true/false)。使用了两种自定义符号 - 一种用于已验证的功能,一种用于未验证的功能。 我已从我的本地 (xcode/swift) iOS 应用程序成功连接到要素服务,要素已正确显示在底图之上。 我已经实现了一个触摸委托并成功检测到何时点击了功能符号。我遇到的问题是试图查询(读取)与被点击的符号关联的 "name" 字段属性。我尝试使用下面的代码,但无法读取属性:

 func geoView(_ geoView: AGSGeoView, didTapAtScreenPoint screenPoint: CGPoint, mapPoint: AGSPoint) {

    if let activeSelectionQuery = activeSelectionQuery {
        activeSelectionQuery.cancel()
    }
    guard let featureLayer = featureLayer else {
        return
    }
    //tolerance level
    let toleranceInPoints: Double = 12
    //use tolerance to compute the envelope for query
    let toleranceInMapUnits = toleranceInPoints * viewMap.unitsPerPoint
    let envelope = AGSEnvelope(xMin: mapPoint.x - toleranceInMapUnits,
                               yMin: mapPoint.y - toleranceInMapUnits,
                               xMax: mapPoint.x + toleranceInMapUnits,
                               yMax: mapPoint.y + toleranceInMapUnits,
                               spatialReference: viewMap.map?.spatialReference)

    //create query parameters object
    let queryParams = AGSQueryParameters()
    queryParams.geometry = envelope


    //run the selection query
    activeSelectionQuery = featureLayer.selectFeatures(withQuery: queryParams, mode: .new) { [weak self] (queryResult: AGSFeatureQueryResult?, error: Error?) in
        if let error = error {
            print("error: ",error)
        }
        if let result = queryResult {
            print("\(result.featureEnumerator().allObjects.count) feature(s) selected")
            print("name: ", result.fields)
        }
    }
}

我正在使用 ArGIS iOS 100.6 SDK。 解决此问题的任何帮助将不胜感激。

featureLayer 选择方法仅更新地图视图显示以在视觉上突出显示要素。

featureLayer,你应该得到 featureTable,然后调用 query()。请注意,有两种方法。对该覆盖进行简单的 query() that gets minimal attributes back, or an override on AGSServiceFeatureTable that allows you to specify that you want all fields back. You might need to specify .loadAll 以获得 name 字段。我们这样做是为了避免下载太多信息(默认情况下我们下载足够的信息来符号化和标记特征)。