core-location

Getting Longitude/Latitude of the User When the viewDidLoad

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 02:50:00
问题 My purpose is to get the longitude/latitude of the user when the view is loaded and to store the values in two variables for later calculations. I don't need to track the user location and to update it, I simply need to get his/her coordinates once . My code looks like this: - (void)viewDidLoad { [super viewDidLoad]; // locationManager update as location locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; locationManager.desiredAccuracy =

Number of “region” monitored by RegionMonitoring, based on users current location in iOS7

耗尽温柔 提交于 2019-11-29 02:29:34
I am working on such a project where apps do the following things: User select a radius (10 meter to 1000 meter) and go to next viewController by pressing "Go" button Here apps Grab users current position and start "region monitoring" based on that current position with selected radius If the user cross that certain boundary (10 meter to 1000 meter) then it gives an "ExitRegion" alert message. And start "region monitoring" again based on users new current position. And the apps keep doing this all the time, both foreground and background mode. I manage to do it & it is working perfectly. Now,

Distance between two coordinates with CoreLocation

三世轮回 提交于 2019-11-29 00:56:25
问题 I need to calculate the distance (in meters and miles) between two coordinates given How can I do that? 回答1: Returns the distance (in meters) from the receiver’s coordinate to the coordinate of the specified location. // Deprecated in iOS 3.2 method - (CLLocationDistance)getDistanceFrom:(const CLLocation *)location // Correct method - (CLLocationDistance)distanceFromLocation:(const CLLocation *)location CLLocation 回答2: The method in the previous answer has been deprecated in iOS 3.2. The new

CLLocationManager geo-fencing/startMonitoringForRegion: vs. startMonitoringForSignificantLocationChanges: vs. 10-minute startUpdating calls

人盡茶涼 提交于 2019-11-29 00:07:53
问题 I am trying to set up an app that will be able to check people's locations in the background, see if they are at a given location, and send a ping to a server if they are. We do not want to drain the energy of our users, so we are attempting to figure out the best solution. I've done substantial reading and I have not found very much information on these methods. I'll go through the pros and cons as I understand them right now startMonitoringForSignificantChanges Description: Based off of wi

Trouble with CLLocation method distanceFromLocation: Inaccurate results

旧街凉风 提交于 2019-11-28 23:49:54
I am trying to use the distanceFromLocation: method to calculate the total distance that I am walking with my iPhone in my hand. So far, I have been searching all over to help remedy my confusing, inaccurate, and seemingly arbitrary results. In these code snippets, theLabel is just a label object that is present in my app's interface, distanceMoved is the variable that I am trying to store the total distance I walked in, and locMan is a location manager that is declared in my @interface file. - (void)viewDidLoad { locMan = [[CLLocationManager alloc] init]; locMan.delegate = self; [locMan

Indoor positioning on iOS with Core Location - not accurate?

淺唱寂寞╮ 提交于 2019-11-28 23:03:53
问题 Using the sample code provided from WWDC, I've been trying to write a simple proof-of-concept app that performs indoor positioning in my office building. I have a floor plan image and replaced the standard image in the demo code. I've also done the requisite mapping of GPS coordinates to pixels for the two anchor points. When I run the app in the simulator and specify static GPS coordinates, I see the position updated as expected in the simulator. When I run it on my phone, however, the

How can I disable any CLRegion objects registered with -startMonitoringForRegion?

自作多情 提交于 2019-11-28 22:54:17
I am using a NavigationController to display a list of geo-fences available to the user. At the top there is a global on/off switch that I would like to use to disable any fences registered with CoreLocation -startMonitoringForRegion. My fences seem to be registering ok and working for the most part, but no matter how many times I disable the fences individually, I'm still getting the purple location arrow indicating that the system is still monitoring my location and/or fences. When I disable my fences individually, this is how I'm doing it. CLLocationCoordinate2D coord; coord.latitude = [

UIBackgroundModes location and significant location changes with region monitoring

…衆ロ難τιáo~ 提交于 2019-11-28 22:48:37
问题 I have an app that uses a combination of startMonitoringForRegion: and startMonitoringSignificantLocationChanges to keep aware of where the user is when the app is in the background. Does this mean that I need to include the location value for the UIBackgroundModes key in the Info.plist ? This is a quote from the docs: The significant-change location service is highly recommended for apps that do not need high-precision location data. With this service, location updates are generated only

iOS8: Blue bar “is Using Your Location” appears shortly after exiting app

亡梦爱人 提交于 2019-11-28 22:06:06
问题 I would like to get the blue bar when tracking in the background, but not when not. My app uses location services all the time when active, so in iOS8 I use the requestWhenInUseAuthorization on CLLocationManager . Normally, the app stops tracking your location when you close it, but the user can choose the option to let the app track his location in the background as well. Therefore, I have the location option for UIBackgroundModes in the Info.plist file. That works perfectly: when switching

Open Maps app from Code - Where/How to find the “Current Location”?

和自甴很熟 提交于 2019-11-28 21:59:14
I am opening Maps app to show directions from user's Current Location to a destination coordinate, from my code. I am using the following code to open the Maps app. I am calling this code when a button is pressed. getCurrentLocation is a method that returns the recently updated location. - (void)showDirectionsToHere { CLLocationCoordinate2D currentLocation = [self getCurrentLocation]; // LINE 1 NSString* url = [NSString stringWithFormat: @"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f", currentLocation.latitude, currentLocation.longitude, destCoordinate.latitude, destCoordinate.longitude