Skip to content

Instantly share code, notes, and snippets.

@aclima93
Last active July 10, 2018 16:41
Show Gist options
  • Save aclima93/bfd02f3e2060bc645b8311919c53e4dc to your computer and use it in GitHub Desktop.
Save aclima93/bfd02f3e2060bc645b8311919c53e4dc to your computer and use it in GitHub Desktop.
ARKit & CoreLocation + Current Locaiton
import CoreLocation
class ARCLViewController: UIViewController, CLLocationManagerDelegate {
var locationManager: CLLocationManager!
var latestLocation: CLLocation?
func setupLocation() {
// Setup location manager
locationManager = CLLocationManager()
locationManager?.delegate = self
// shouldn't need better accuracy for walking between POIs
locationManager?.desiredAccuracy = kCLLocationAccuracyNearestTenMeters
// request location updates
locationManager?.startUpdatingLocation()
locationManager?.requestWhenInUseAuthorization()
}
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
print("LocationManager didFailWithError: %@", error)
// TODO: handle error
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
print("LocationManager didUpdateLocations: %@", locations)
// handle updated location
if (locations.count > 0) {
latestLocation = locations.last!
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment