Reputation: 324
I am using API Google maps. When I click on the button, I call the method locationManager.startUpdatingLocation()
. But this method monitors my location, and I need to take data (coordinates) only once. What should I use in this case?
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let userLocation :CLLocation = locations[0] as CLLocation
print("user latitude = \(userLocation.coordinate.latitude)")
print("user longitude = \(userLocation.coordinate.longitude)")
}
Upvotes: 0
Views: 27
Reputation: 100503
Do
locationManager.stopUpdatingLocation()
also you can add once bool
variable
Upvotes: 1