Is there anyway to optimize the following feature selection code? Currently, there's about a second delay between when the user taps the screen in the iPad simulator and when the polygon feature is highlighted after being selected. I can't give an exact count, but there are a LOT of polygons in the "Polygons Layer" feature layer. Thanks for any help!
func handleSelectionByTapAtScreenPoint(screenPoint: CGPoint) {
// Select the feature in the Polygons Layer that was tapped.
let layers = self.mapView.map?.operationalLayers as? [AGSLayer]
for layer in layers! {
if let featureLayer = layer as? AGSFeatureLayer, featureLayer.name == "Polygons Layer" {
self.mapView.identifyLayer(featureLayer, screenPoint: screenPoint, tolerance: 1, returnPopupsOnly: false, maximumResults: 5) { (identifyLayerResult: AGSIdentifyLayerResult) in
for geoElement in identifyLayerResult.geoElements {
if let feature = geoElement as? AGSFeature {
// Select the feature
featureLayer.select(feature)
}
}
}
}
}
}