Hi, newcomer to arcGIS here. I work a university, and they have an entire campus maps division that has used arcGIS. Until now, they've only used it for web, but my colleague (android dev) and I (iOS dev) are working out way through the docs to get some of the same functionality working on a mobile platform.
I was wondering whether I'm doing this incorrectly?
func geoView(_ geoView: AGSGeoView, didTapAtScreenPoint screenPoint: CGPoint, mapPoint: AGSPoint) {
self.mapView.identifyLayers(atScreenPoint: screenPoint, tolerance: 10.0, returnPopupsOnly: true) { (results, error) in
guard let results = results else { return }
if let result = results.first,
let featureLayer = result.layerContent as? AGSFeatureLayer,
let geoElement = result.geoElements.first,
let name = geoElement.attribut
func geoView(_ geoView: AGSGeoView, didTapAtScreenPoint screenPoint: CGPoint, mapPoint: AGSPoint) {
self.mapView.identifyLayers(atScreenPoint: screenPoint, tolerance: 10.0, returnPopupsOnly: true) { (results, error) in
guard let results = results else { return }
if let result = results.first,
let featureLayer = result.layerContent as? AGSFeatureLayer,
let geoElement = result.geoElements.first,
let name = geoElement.attributes["Name"] as? String,
let desc = geoElement.attributes["Description"] as? String,
let feature = geoElement as? AGSFeature {
featureLayer.select(feature)
}
}
No matter where or which layer I tap on the map, results is always returned as an empty array. I know that it's not an issue with the layers, because my friend has gotten it to work just fine on his kotlin equivalent. His code is similar, except that I think they handle the response from identifyLayersAsync with identityFuture.get()
@IBOutlet weak var mapView: AGSMapView!
var layer: AGSFeatureLayer {
return AGSFeatureLayer(featureTable: AGSServiceFeatureTable(url: URL_))
}
override func viewDidLoad() {
super.viewDidLoad()
setupMap()
}
private func setupMap() {
let map = AGSMap(basemapType: .lightGrayCanvasVector, latitude: latitude, longitude: longitude, levelOfDetail: 10)
mapView.map = map
mapView.touchDelegate = self
mapView.callout.delegate = self
map.operationalLayers.add(self.layer)
}
I've looked all over for help, but I haven't found one that related so I hope this was the right thing to do. Thank you
Solved! Go to Solution.
I think it's because you're setting returnPopupsOnly to true in your identify call.
If you don't have popups defined on your layers, this would mean you'd get no results back. See ArcGIS Runtime SDK for iOS: AGSGeoView Class Reference
If set to YES, only layers with popups will be retured. If the layer does not have popups an error will be returned. If set to NO, all layers (with or without popups) will be retured.
I think it's because you're setting returnPopupsOnly to true in your identify call.
If you don't have popups defined on your layers, this would mean you'd get no results back. See ArcGIS Runtime SDK for iOS: AGSGeoView Class Reference
If set to YES, only layers with popups will be retured. If the layer does not have popups an error will be returned. If set to NO, all layers (with or without popups) will be retured.
I love you.
I think that's the best response I've seen here Glad to have helped!