cllocationmanager

MKMapView and CLLocationManager

帅比萌擦擦* 提交于 2019-11-27 13:48:29
问题 I want to use a MKMapView to display the user current location using the default breathing blue pin and I want to record the user movement at the same time. Is there any way that I could use the GPS manager (not sure if this is a CLLocationManager) the MKMapView uses when we enabled it to show user location? I know that I can create my own CLLocationManager. But this feels like adding an overhead to my application and I would like the map and my tracking to remain in sync. I already explored

Reverse geocoding in Swift 4

烈酒焚心 提交于 2019-11-27 13:19:08
I'm attempting to write a simple method that's fed CLLocationDegrees and returns a CLPlacemark . Looking at Apple's documentation , it seems like a simple task. Below is what I've dumped into a playground: import CoreLocation // this is necessary for async code in a playground import PlaygroundSupport // this is necessary for async code in a playground PlaygroundPage.current.needsIndefiniteExecution = true func geocode(latitude: CLLocationDegrees, longitude: CLLocationDegrees) -> CLPlacemark? { let location = CLLocation(latitude: latitude, longitude: longitude) let geocoder = CLGeocoder() var

How to rotate a Direction Arrow to particular location

别等时光非礼了梦想. 提交于 2019-11-27 11:58:58
In my app I have a latitude-longitude of 1 fix location. Now user with iPhone device can move anywhere and even he rotate his device, the arrow (some uiimageview) should point to that fix location so User will get direction to that location every time. I tried as follows. -(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { CLLocationCoordinate2D here = newLocation.coordinate; [self calculateUserAngle:here]; } -(void) calculateUserAngle:(CLLocationCoordinate2D)user { NSLog(@"my destination is %f ; %f",

Implement CLLocationManagerDelegate methods in Swift

谁说我不能喝 提交于 2019-11-27 11:49:00
I've been trying to get this to work for awhile now, and I've come here to ask- how do I go about with using the CLLocationManagerDelegate methods in Swift? I've put this at the top of my class: var locationManager = CLLocationManager() I've put the following into my viewDidLoad method: locationManager.delegate = self locationManager.distanceFilter = kCLDistanceFilterNone locationManager.desiredAccuracy = kCLLocationAccuracyBest locationManager.startUpdatingLocation() And I've tried using these delegate methods with no avail: func locationManager(manager: CLLocationManager!, didUpdateLocations

How to handle “Don't Allow” for location manager?

偶尔善良 提交于 2019-11-27 11:42:39
问题 I haven't think of this yet now . Till now whenever device was asking me use location update I was allowing it . But when now I am not allowing then it the location manager gives me kclErrorDenied and the location manager can not start again until I restart the application . So my question is that should I give a message to restart the app to the user or is there a solution to start working the location manager again . thanks . The Error : ERROR,Time,288787555.078,Function,"void

iOS CLLocationManager in a separate class

左心房为你撑大大i 提交于 2019-11-27 11:36:47
I have multiple view controllers that need to get the user's location, so I wanted to create a separate class that the ViewControllers can call to get the user's latest location. locationManager:didUpdateToLocation:fromLocation returns void. How do I pass the latitude and longitude data back to my ViewControllers as soon as the user's latitude and longitude is calculated? I could try writing getters and setters in my locationManaging class, but if I do that, how do I know when to call the latitude getter and longitude getter methods from my ViewController class? How do I hold the

Show Current Location and Update Location in MKMapView in Swift

☆樱花仙子☆ 提交于 2019-11-27 11:26:57
I am learning how to use the new Swift language (only Swift, no Objective-C). To do it, I want to do a simple view with a map ( MKMapView ). I want to find and update the location of the user (like in the Apple Map app). I tried this, but nothing happened: import MapKit import CoreLocation class MapView : UIViewController, CLLocationManagerDelegate { @IBOutlet weak var map: MKMapView! var locationManager: CLLocationManager! override func viewDidLoad() { super.viewDidLoad() if (CLLocationManager.locationServicesEnabled()) { locationManager = CLLocationManager() locationManager.delegate = self

didUpdateLocations instead of didUpdateToLocation

爱⌒轻易说出口 提交于 2019-11-27 11:24:59
With the release of iOS6 Apple wants us to use didUpdateLocations instead of didUpdateToLocation. Can anyone explain how to properly use didUpdateLocations? I asume you used the following delegate to get the last position? - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation The delegate above is deprecated in iOS 6. Now the following should be used: - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations In order to get the last position, simply get the last object of the

ios, startMonitoringSignificantLocationChanges - sometimes breaks monitoring

为君一笑 提交于 2019-11-27 11:00:50
问题 I have strange problem with updating user's location. Sometimes my app updates location but from time to time breaks updating. I do not know where is problem, my code (from AppDelegate.m) is below: - (void)applicationDidEnterBackground:(UIApplication *)application { NSLog(@"Went to Background"); // Only monitor significant changes [locationManager startMonitoringSignificantLocationChanges]; } - (void)applicationDidBecomeActive:(UIApplication *)application { // Start location services

Why is my CLLocationmanager delegate not getting called?

空扰寡人 提交于 2019-11-27 10:49:52
问题 I'm not getting any location callbacks on either sim or device. I've got this code being called: - (void)startLocationCallbacks: (NSObject*) ignore { locationManager.delegate = self; locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation; locationManager.distanceFilter = MINIMUM_METERS; [locationManager startUpdatingLocation]; NSLog(@"[DEBUG] [locationManager startUpdatingLocation] (%@, %@)", locationManager, locationManager.delegate); } and log statements at the top of both -