cllocation

Calculate Total Traveled Distance iOS Swift

允我心安 提交于 2019-11-27 08:08:21
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 able to work out the swift syntax Here is what I've worked out so far, not sure if I'm doing it right.

Calculating bearing between two CLLocation points in Swift [duplicate]

断了今生、忘了曾经 提交于 2019-11-27 07:51:25
This question already has an answer here: CLLocation Category for Calculating Bearing w/ Haversine function 6 answers I'm trying to calculate a bearing between two CLLocation points in swift-only code. I've run into some difficulty and was assuming this is a pretty simple function. Stack overflow didn't seem to have anything listed. func d2r(degrees : Double) -> Double { return degrees * M_PI / 180.0 } func RadiansToDegrees(radians : Double) -> Double { return radians * 180.0 / M_PI } func getBearing(fromLoc : CLLocation, toLoc : CLLocation) { let fLat = d2r(fromLoc.coordinate.latitude) let

How to check if MKCoordinateRegion contains CLLocationCoordinate2D without using MKMapView?

て烟熏妆下的殇ゞ 提交于 2019-11-27 00:37:52
问题 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 -

CLLocationManager and accuracy issues - any experiences?

别等时光非礼了梦想. 提交于 2019-11-26 23:58:37
问题 So I am dealing with some accuracy issues with iPhone GPS. I have an app which uses location. In the delegate method locationManager: didUpdateToLocation: fromLocation: I am being returned a location. From a bit of research, it appears the GPS isn't always accurate on the first result it returns, even when setting desiredAccuracy property to kCLLocationAccuracyBest . In order to get around this, I don't call stopUpdatingLocation before it's returned newLocation: at least 3 times (this is very

How to stop multiple times method calling of didUpdateLocations() in ios

时间秒杀一切 提交于 2019-11-26 22:00:36
This my code...... -(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations { location_updated = [locations lastObject]; NSLog(@"updated coordinate are %@",location_updated); latitude1 = location_updated.coordinate.latitude; longitude1 = location_updated.coordinate.longitude; self.lblLat.text = [NSString stringWithFormat:@"%f",latitude1]; self.lblLon.text = [NSString stringWithFormat:@"%f",longitude1]; NSString *str = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/geocode/json?latlng=%f,%f&sensor=false",latitude1,longitude1]; url = [NSURL

NSPredicate With FUNCTION Not Working

微笑、不失礼 提交于 2019-11-26 21:57:15
问题 My predicate keeps on crashing my app with the message Unsupported function expression FUNCTION(SELF, "filterDistanceWithLatitude:" , latitude, longitude ). Does anyone know how to fix this? - (void)setUpFetchedResultsController { NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"NextTime"]; //Retrieve data for the place entity request.sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES selector:@selector

Zoom MKMapView to fit polyline points

孤者浪人 提交于 2019-11-26 19:59:47
问题 I have an array, allCollections, that holds programmatically-created arrays of CLLocations the user has recorded through my iOS app. Each sub-array in allCollections holds all the location points in a trip taken. I draw MKPolylines off of the CLLocations in the arrays in allCollections to represent those trips on an MKMapView. My question is this: With the polylines added to the map, how would I go about programmatically zooming and centering the map to display all of them? 回答1: -(void

What do horizontalAccuracy and verticalAccuracy of a CLLocation refer to?

风格不统一 提交于 2019-11-26 19:56:40
问题 I've been working on a location based app recently and am noticing some strange values for CLLocation. I often get a horizontalAccuracy of 1414 and a verticalAccuracy of -1 . Any clue what this indicates? As far as I can tell, these points are often very accurate. What is the difference between verticalAccuracy and horizontalAccuracy? 回答1: The -1 for verticalAccuracy indicates that the altitude in the CLLocation is not valid. You only get altitude with a 3D GPS position. The 1414 for

CLLocation Category for Calculating Bearing w/ Haversine function

∥☆過路亽.° 提交于 2019-11-26 18:46:06
I'm trying to write a category for CLLocation to return the bearing to another CLLocation. I believe I'm doing something wrong with the formula (calculous is not my strong suit). The returned bearing is always off. I've been looking at this question and tried applying the changes that were accepted as a correct answer and the webpage it references: Calculating bearing between two CLLocationCoordinate2Ds http://www.movable-type.co.uk/scripts/latlong.html Thanks for any pointers. I've tried incorporating the feedback from that other question and I'm still just not getting something. Thanks Here

IOS Getting location updates when app terminated without using significantChange

一笑奈何 提交于 2019-11-26 16:36:57
问题 I apologise for the redundancy of this topic, but in spite all the given answers, I can't identify the possibility of getting accuracyBest location updates when the app is terminated. I don't want to use monitoringSignificantChange, I want the best possible accuracy; I won't submit the app on the AppStore, so Apple restrictions are not a problem either. I have gone through these: -Location update even when app is killed/terminated -iOS update location even when app is terminated -Working with