Hi Ive been trying to get an elevation based on a point. here is my code, but the get elevation part dont respond to the completion handler
let surface = AGSSurface()
// Create an elevation source.
let elevationURL = URL(string: "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")
let elevationSource = AGSArcGISTiledElevationSource(url: elevationURL!)
surface.elevationSources.append(elevationSource)
elevationSource.load { error in
if error == nil {
// Add the elevation source to the surface.
surface.elevation(for: hasCurrentPoint) { elevation, error in
print("vince!!!")
}
}
}
Solved! Go to Solution.
I'm betting that the AGSSurface() is deallocated before the completion block is called. Just set up an instance level variable to hold on to the surface.
Incidentally, you don't need to explicitly call load(). When you call any asynchronous method on a loadable object, we'll automatically load it if it isn't already loaded. That can help to make your code a little cleaner.
You can start to avoid these sorts of issues by adopting Swift Concurrency. You can read more about that in this blog post.
Hope that helps!
Nick.
I'm betting that the AGSSurface() is deallocated before the completion block is called. Just set up an instance level variable to hold on to the surface.
Incidentally, you don't need to explicitly call load(). When you call any asynchronous method on a loadable object, we'll automatically load it if it isn't already loaded. That can help to make your code a little cleaner.
You can start to avoid these sorts of issues by adopting Swift Concurrency. You can read more about that in this blog post.
Hope that helps!
Nick.