Take a look at the sample app. You can download it form the App Store and explore capabilities. Each sample shows the code behind directly in the app, but it's also available on GitHub.
But if you're looking to track the current centerpoint of the map display, you can use AGSMapView.viewpointChangedHandler. You would then want to call AGSMapView.currentViewpointWithType() and pass in .centerAndScale as the type. You'll get an AGSViewpoint back, and look at the targetGeometry. It'll be an AGSPoint that's the center of the map (you'll have to cast to AGSPoint).
The point's coordinates will be in the spatial reference of the map (in this case Web Mercator) which is probably not what you want to output. You'd need to project it to WGS84. We also have a AGSCoordinateFormatter class that can help.
See this code for an example:
mapView.viewpointChangedHandler = { [weak self] in
guard let self = self else { return }
if let center = self.mapView.currentViewpoint(with: .centerAndScale)?.targetGeometry as? AGSPoint {
// Format the Lat Lon etc. using a standard format
if let latLonString = AGSCoordinateFormatter.latitudeLongitudeString(from: center, format: .degreesMinutesSeconds, decimalPlaces: 1) {
print(latLonString)
}
// Get the coordinates manually…
if let wgs84center = AGSGeometryEngine.projectGeometry(center, to: .wgs84()) as? AGSPoint {
print("Lat \(wgs84center.y), Lon \(wgs84center.x)")
}
}
}
That will output something like this to the Xcode console…
19 56 53.8N 100 32 17.0W
Lat 19.948264571145458, Lon -100.53804579499798
19 58 51.9N 100 42 37.8W
Lat 19.98109671769453, Lon -100.71050437417519
20 00 03.9N 100 48 55.8W
Lat 20.001080434190495, Lon -100.81549113806531
20 00 25.0N 100 50 46.6W
Lat 20.006942571870393, Lon -100.84629108361138
20 00 25.0N 100 50 46.7W
Lat 20.006942719211626, Lon -100.84629185776355
Please note that ENC layers require a Runtime Standard License when you're ready to deploy your app.