我想使用折线从SketchEditor.polyline创建的Featurelayer中查询要素。但是,我总是得到结果,好像我按多边形查询结果。代码如下:
func featureSpaceSelection(mapGeometry:AGSGeometry){
let queryParams = AGSQueryParameters()
queryParams.geometry = mapGeometry
//选中查询features
self.featureLayer.selectFeatures(withQuery: queryParams, mode: AGSSelectionMode.new) { (queryResult:AGSFeatureQueryResult?, error:Error?) -> Void in
print("geometry Type",queryResult?.geometryType.rawValue)
if let error = error {
print(error)
self.selectedFeatures.removeAll(keepingCapacity: false) //清空查询选项
}
else if let result = queryResult {
let features = result.featureEnumerator().allObjects
self.featureLayer.select(features)
self.selectedFeatures = features
//发送通知
let NotifyChatSelectFeatures = NSNotification.Name(rawValue:"notifyChatSelectFeatures")
NotificationCenter.default.post(name: NotifyChatSelectFeatures, object: features)
//获取feature信息
for element in features{
//添加覆盖物
self.graphicsOverlay.graphics.add(self.polygonStyle(geometry: element.geometry!))
}
}
}
}
mapGeometry是sketchEditor.geometry(),它是通过self.sketch.start(with:nil,creationMode:.polyline)创建的。