cllocation

Order of CLLocation objects in -distanceFromLocation:

∥☆過路亽.° 提交于 2020-01-03 11:48:04
问题 This is my first time posting a question here, but I have found a lot of help from other people's questions. My question refers to the -distanceFromLocation: function in CLLocation . I had assumed that finding the distance between point A and point B would be the same as that between point B and point A, but I have found that it is not. I have tested this in a very simple case: CLLocation *test1 = [[CLLocation alloc] initWithLatitude:37.529530 longitude:-122.259232]; CLLocation *test2 = [

How add polyline in mapView

故事扮演 提交于 2020-01-03 06:51:32
问题 I would insert in my mapview an polyline! I made it in this way CLLocationCoordinate2D coord[2]; coord[1].latitude = 45.42207; coord[1].longitude = 9.123888; coord[2].latitude = 45.422785; coord[2].longitude = 9.12377; MKPolyline *polyline = [[MKPolyline alloc] init]; polyline = [MKPolyline polylineWithCoordinates:coord count:2]; [self.mapView addAnnotation:polyline]; But don't work and there's this error: EXC_BAD_ACCESS. What's it wrong? 回答1: try this CLLocationCoordinate2D coord[2]; coord[0

Looking for business name information from coordinates using CLLocation and/or Mapkit

ぃ、小莉子 提交于 2020-01-03 06:21:05
问题 I'm trying to use coordinates returned using CLLocationManager to see if they are a close match for any local business - if I happened to be standing in a Starbucks for example, I would want my app to suggest that based on my coordinates I was standing in Starbucks. If I was 20 metres outside Starbucks, but it was the closest address to where I was standing, I would want it to suggest 'Starbucks'. I can return CLPlacemarks no problem, but the information they contain does not contain the

Distance between Long Lat coord using SQLITE

一曲冷凌霜 提交于 2020-01-01 00:44:07
问题 I've got an sqlite db with long and lat of shops and I want to find out the closest 5 shops. So the following code works fine. if(sqlite3_prepare_v2(db, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) { while (sqlite3_step(compiledStatement) == SQLITE_ROW) { NSString *branchStr = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 0)]; NSNumber *fLat = [NSNumber numberWithFloat:(float)sqlite3_column_double(compiledStatement, 1)]; NSNumber *fLong = [NSNumber

Does the internal GPS antenas stop working immediately after calling CLLocationManager stopUpdatingLocation

╄→尐↘猪︶ㄣ 提交于 2019-12-31 07:25:12
问题 Here is my scenario. In my app there is no need of continuously monitoring user location, but I need the location to be as accurate as possible. So I just call CLLocationManager startUpdatingLocation with kCLLocationAccuracyBestForNavigation set as desiredAccuracy, and after I get the location with my desired accuracy (by comparing newLocation.horizontalAccuracy with predefined value) I want to stop the location update and revoke update again after several seconds. But when I call

What does the const specifier do, before a pointer to object?

家住魔仙堡 提交于 2019-12-31 03:21:26
问题 If I have a C-string like this: const char* str= "hello"; I know well that I can't change any character of the string because the pointer is const. But if I have this: - (CLLocationDistance)distanceFromLocation:(const CLLocation *)location I can still mutate the object state using it's methods. If the pointer is to a NSMutableString, I'm still able to mutate it. Then what does the const stand for? 回答1: In that method declaration, location is a pointer to a constant CLLocation . But when you

How to store CLLocationCoordinate2D?

故事扮演 提交于 2019-12-30 03:20:07
问题 I'm attempting to build an application that builds and saves routes similar to map my run. I'm using the Breadcrumb sample code, specifically the CrumbPath and CrumbPathView as the base of my routes, from Apple. Two questions: If I try to access the MKMapPoint *points object of the CrumbPath like so: [_route lockForReading]; NSLog(@"%@", _route.points); NSLog(@"%d", _route.pointCount); [_route unlockForReading]; my app crashes, saying: Thread 1: EXC_BAD_ACCESS (code: 1, address: 0x9450342d)

Core Location region monitoring

旧城冷巷雨未停 提交于 2019-12-29 14:58:34
问题 Does anyone know any knowledge of using this: - (void) startMonitoringForRegion:(CLRegion *)region desiredAccuracy:(CLLocationAccuracy)accuracy I am trying to implement it into my project but: - (void) locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region is never being called? Does anyone have any example code or know why this is happening? My code is as follows. I created a method like this in my own LocationManager class: - (void)

Core Location region monitoring

无人久伴 提交于 2019-12-29 14:57:56
问题 Does anyone know any knowledge of using this: - (void) startMonitoringForRegion:(CLRegion *)region desiredAccuracy:(CLLocationAccuracy)accuracy I am trying to implement it into my project but: - (void) locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region is never being called? Does anyone have any example code or know why this is happening? My code is as follows. I created a method like this in my own LocationManager class: - (void)

CLLocation speed

故事扮演 提交于 2019-12-28 12:05:09
问题 I am developing GPS application. Do you know about how to detect speed of mobile device ? Actually, I need to detect the speed every 2 seconds. I know didUpdateToLocation method is called when location changed. - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation But I think this method is not suitable for my issue. So, Do I need to check speed of [CLLocationManager location] in 2 seconds ? Any suggestion ?