cllocation

What does horizontalAccuracy exactly mean?

别来无恙 提交于 2019-11-29 08:10:06
问题 I am working on an iOS application using location services. Having a background in experimental physics, I am wondering what exactly horizontalAccuracy in a location found in locationManager:didUpdateToLocation:fromLocation: stands for. The documentation is a bit sparse... I assume that the accuracy gives a confidence interval based on a gaussian (or poisson?) distribution. Thus, with a certain probability, the actual position is within a circle with a radius of horizontalAccuracy , but could

put CLLocationCoordinate2D into CLLocation for Swift

[亡魂溺海] 提交于 2019-11-29 06:16:53
问题 I have a method I want to call however when I get back the center of the map, it is in CLLocationCoordinate2D type. How do I put the results of CLLocationCoordinate2D into CLLocation? 回答1: Figured it out. When mapView changes region, get the Lat and Lon from CLLocationCoordinate2D and create a CLLocation variable with the lat and lon passed in. func mapView(mapView: MKMapView!, regionDidChangeAnimated animated: Bool){ var centre = mapView.centerCoordinate as CLLocationCoordinate2D var getLat:

How to measure the distance in meters between two CLLocations?

一笑奈何 提交于 2019-11-29 05:37:34
How can I get the distance in meters between two CLLocation s? CLLocation doesn't provide any method to do it, it seeems. CLLocationDistance distance = [aCLLocationA distanceFromLocation:aCLLocationB]; // distance is a double representing the distance in meters CLLocationDistance distance = [secondLocation distanceFromLocation:firstLocation]; // distance is expressed in meters CLLocationDistance kilometers = distance / 1000.0; // or you can also use this.. CLLocationDistance meters = distance; NSString *distanceString = [[NSString alloc] initWithFormat: @"%f", kilometers]; flot

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

CLLocationManager on iPhone Simulator fails with kCLErrorDomain Code=0

[亡魂溺海] 提交于 2019-11-28 21:03:34
CLLocationManager on iPhone Simulator is supposed to fake Cupertino (isn't it?) but it does NOT, it fails with kCLErrorDomain Code=0 instead. LocationManager's delegate receives the message didFailWithError . This method is implemented to log the error and the console outputs the following: Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)" I was working on a real project when I ran into this problem but it is pointless to discuss my code because I downloaded "Locations" sample code (updated 2010-06-22 for iOS 4) from the dev center and the

iPhone 3.0 Compass: how to get a heading?

▼魔方 西西 提交于 2019-11-28 20:56:16
I'm relatively new to Objective-C and really don't know much about it yet, so I apologise for what is probably a really amateurish question. I'm trying to get the magnetic heading from CLHeading and CLLocationDirection. However I'm getting compile errors for this line of code: locationLabel.text = [[[location course] magneticHeading] stringValue]; The errors are: warning: invalid receiver type 'CLLocationDirection' error: cannot convert to a pointer type I don't really understand what I'm doing wrong here. Please help! Here are the steps needed to use the compass. 1) check the availability: if

Swift - CLGeocoder reverseGeocodeLocation completionHandler closure

只愿长相守 提交于 2019-11-28 18:19:46
What I'm trying to do is pass a CLLocation to the function getPlacemarkFromLocation which then uses the passed CLLocation through reverseGeocodeLocation to set the CLPlacemark? that will be returned. I'm having issues creating the completionHandler closure in reverseGeocodeLocation , it's throwing a compiler error/crash: In Swift, CLGeocodeCompletionHandler is CLGeocodeCompletionHandler = (AnyObject[]!, NSError!) -> Void according to the documentation AnyObject[]! is supposed to contain CLPlacemark objects just like the Objective-C version. Here's my current code: class func

How to check if MKCoordinateRegion contains CLLocationCoordinate2D without using MKMapView?

六眼飞鱼酱① 提交于 2019-11-28 17:36:42
I need to check if user location belongs to the MKCoordinateRegion. I was surprised not to find simple function for this, something like: CGRectContainsCGPoint(rect, point) . I found following piece of code: CLLocationCoordinate2D topLeftCoordinate = CLLocationCoordinate2DMake(region.center.latitude + (region.span.latitudeDelta/2.0), region.center.longitude - (region.span.longitudeDelta/2.0)); CLLocationCoordinate2D bottomRightCoordinate = CLLocationCoordinate2DMake(region.center.latitude - (region.span.latitudeDelta/2.0), region.center.longitude + (region.span.longitudeDelta/2.0)); if

How to find out distance between coordinates?

非 Y 不嫁゛ 提交于 2019-11-28 16:21:03
I want to make it so that it will show the amount of distance between two CLLocation coordinates. Is there someway to do this without a complex math formula? If there isn't how would you do it with a formula? Glenn Howes CLLocation has a distanceFromLocation method so given two CLLocations: CLLocationDistance distanceInMeters = [location1 distanceFromLocation:location2]; or in Swift 4: //: Playground - noun: a place where people can play import CoreLocation let coordinate₀ = CLLocation(latitude: 5.0, longitude: 5.0) let coordinate₁ = CLLocation(latitude: 5.0, longitude: 3.0) let

Decoding the CLLocationAccuracy const's

北城以北 提交于 2019-11-28 15:24:18
问题 the following are listed in CLLocation.h but from my experience they are deceiving names- possibly originally thought up to serve two purposes, 1. to test the accuracy of the location returned, but also 2. to set how hard the location manager works, specifically what is enabled (gps (how many sat channels), how hard the wifi works, triangulation etc. extern const CLLocationAccuracy kCLLocationAccuracyBestForNavigation; // (raw value: -2) extern const CLLocationAccuracy kCLLocationAccuracyBest