core-location

Calculate Total Traveled Distance iOS Swift

孤者浪人 提交于 2019-11-26 14:01:49
问题 How can I calculate the total distance traveled use CoreLocation in Swift I haven't been able to so far find any resources for how to do this in Swift for iOS 8, How would you calculate the total distance moved since you began tracking your location? From what I've read so far, I need to save location of a points, then calculate the distance between current point, and last point, then add that distance to a totalDistance variable Objective-C is extremely unfamiliar to me, so I haven't been

iOS GPS tracking app that runs all the time

ⅰ亾dé卋堺 提交于 2019-11-26 13:18:15
问题 I am trying to make an app to track the user GPS all the time, this app is a kind of car GPS tracker to get the location of driver all the time and send it to server. I have tried to add "location updates" to the "background modes" but the app will automatically suspends after 10 mins when going into background. Is there a way to make this app run all the time and get the GPS location? 回答1: You have two options here: 1) Regular location tracking. This type of tracking works with

StartUpdateLocations in Background, didUpdatingToLocation only called 10-20 times

大城市里の小女人 提交于 2019-11-26 13:04:13
问题 Testing Device: iPhone 5 (iOS 7) I have an app that uses RegionMonitoring and updateLocation . If a region is entered, didEnterRegion is called as expected. Then I call startUpdatingLocation . But the method didUpdateToLocation is only called 10-20 times while it should update the location until the timer fires. The relevant code: CLLocationManager *_locationManager; NSTimer *_timer; -(void)initLocationManager { _locationManager = [[CLLocationManager alloc] init]; _locationManager.delegate =

How to find your current location with CoreLocation

谁说我不能喝 提交于 2019-11-26 12:22:04
问题 I need to find my current location with CoreLocation , I tried multiple methods but so far my CLLocationManager has only returned 0\'s.. ( 0.000.00.000 ). Here\'s my code ( updated to work ): Imports : #import <CoreLocation/CoreLocation.h> Declared : IBOutlet CLLocationManager *locationManager; IBOutlet UILabel *latLabel; IBOutlet UILabel *longLabel; Functions : - (void)getLocation { //Called when needed latLabel.text = [NSString stringWithFormat:@\"%f\", locationManager.location.coordinate

Core Data and Core Location

百般思念 提交于 2019-11-26 11:57:43
问题 I have a Core Data database with latitude and longitude properties. Is there a way to use Core Location\'s getDistanceFrom: method to find the five nearest locations to a CLLocation obtained from the GPS? Do I have to load all the objects using Core Data and parse through them, using getDistanceFrom: on each one or is there an easier way? 回答1: You will have to iterate through them one by one; as far as I know there is no other way to do it. However, you can make this more efficient by using a

Current location permission dialog disappears too quickly

Deadly 提交于 2019-11-26 11:56:15
问题 My app takes the user\'s location, gets the co-ordinates , and provides a distance to or from their destination or origin. All these possible destinations are shown in a table view, so I\'m getting the users co-ordinates at the same time as populating the table. The only thing is, the alert view that asks for the users location appears then disappears so quickly it\'s impossible to click it! Is there any way to manually present this alert when the app first loads? I tried getting the user\'s

Optimizing CLLocationManager/CoreLocation to retrieve data points faster on the iPhone

一曲冷凌霜 提交于 2019-11-26 11:49:58
问题 I\'m currently using CoreLocation + CLLocationManager in order to compare a users current location to N amount of other locations. The problem I\'m facing is I\'m dealing with urban areas where locations are close to each other, so I need to pin point the location of the user as accurately as the device allows without sacrificing too much time. My calculations are darn accurate, the problem is, it takes far too long to collect 10 samples. I\'ll paste my filters/accuracy respective code below.

How can I prompt the user to turn on location services after user has denied their use

扶醉桌前 提交于 2019-11-26 10:20:01
问题 I have an application with an explicit user interaction that makes use of the user\'s current location. If the user denies access to location services, I would still like subsequent uses to prompt the user to go to settings and re-enable location services for my app. The behavior I want is that of the built-in Maps app: Reset location warnings in Settings > General > Reset > Reset Location Warnings. Start Maps app. Tap Current Location button in lower left corner. Maps prompts with \"\"Maps\"

What&#39;s the easiest way to get the current location of an iPhone?

和自甴很熟 提交于 2019-11-26 10:17:19
问题 I already know how to use the CLLocationManager, so I could do it the hard way, with delegates and all that. But I\'d like to have a convenience method that just gets the current location, once, and blocks until it gets the result. 回答1: What I do is implement a singleton class to manage updates from core location. To access my current location, I do a CLLocation *myLocation = [[LocationManager sharedInstance] currentLocation]; If you wanted to block the main thread you could do something like

Why the CLLocationManager delegate is not getting called in iPhone SDK 4.0?

若如初见. 提交于 2019-11-26 09:56:45
问题 This is the code that I have in my AppDelegate Class - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { CLLocationManager *locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; locationManager.distanceFilter = 1000; // 1 Km locationManager.desiredAccuracy = kCLLocationAccuracyKilometer; [locationManager startUpdatingLocation]; } And this is the delegate method i have in my AppDelegate Class //This is