I have a custom view that sits on top of the map that has a list of misc images (a toolbar of sorts). Each image has the ability to be dragged across the screen and then wherever they drop the image, I would like to be able to perform the mapView.identifyLayer method to identify/read layer data from the screen point where the drop occurred. When this method is called outside of a touch event, it goes into the function, but it never returns with a completion. It hangs forever. The same code works fine when called inside the geoView 'didTapAtScreenPoint' event.
Solved! Go to Solution.
I assume you are calling self.mapView.identifyLayer() from the main thread, and so I'm pretty sure that what's happening is that you're blocking the main thread with your group.wait() call and then the mapView is blocked when it tries to call back into your completion closure. You can learn more about Runtime and threading here: https://community.esri.com/community/developers/native-app-developers/arcgis-runtime-sdk-for-ios/blo...
Rather than forcing a synchronous pattern into your function, you should define getFeatureDataAtLocation() with a callback method too. See my answer to a not entirely unrelated question from yesterday.
Perhaps one day Swift will finally adopt async but until then you should use this pattern.
I assume you are calling self.mapView.identifyLayer() from the main thread, and so I'm pretty sure that what's happening is that you're blocking the main thread with your group.wait() call and then the mapView is blocked when it tries to call back into your completion closure. You can learn more about Runtime and threading here: https://community.esri.com/community/developers/native-app-developers/arcgis-runtime-sdk-for-ios/blo...
Rather than forcing a synchronous pattern into your function, you should define getFeatureDataAtLocation() with a callback method too. See my answer to a not entirely unrelated question from yesterday.
Perhaps one day Swift will finally adopt async but until then you should use this pattern.
You're absolutely right... I'm a bonehead : ) I do get results when I add a callback/completion to getFeatureDataAtLocation().
Thank you for the help!