Update Location in Mapview Xcode

前端 未结 2 1180
我在风中等你
我在风中等你 2021-01-26 05:37

In my current project.

I need user\'s location at every 50 meter user move.

So Basically After open application every 50 meter change I

2条回答
  •  -上瘾入骨i
    2021-01-26 06:14

    set your location track in

    //create location manager object
    locationManager = [[CLLocationManager alloc] init];
    
    //there will be a warning from this line of code
    [locationManager setDelegate:self];
    
    //and we want it to be as accurate as possible
    //regardless of how much time/power it takes
    [locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
    
    //set the amount of metres travelled before location update is made
    [locationManager setDistanceFilter:50];
    

    and add

    if ([CLLocationManager locationServicesEnabled]) {
        [self.locationManager startUpdatingLocation];
    }
    

    Update

    -(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
    CLLocation *location = locations.lastObject;
    NSLog(@"%@", location.description);
    
     //In here you get all details like
    
       NSLog(@"latitude = %@",location.coordinate.latitude);
       NSLog(@"longitude = %@",location.coordinate.longitude);
       NSLog(@"altitude = %@",location.altitude);
       NSLog(@"horizontalAccuracy = %@",location.horizontalAccuracy);
       NSLog(@"verticalAccuracy = %@",location.verticalAccuracy);
       NSLog(@"timestamp = %@",location.timestamp);
       NSLog(@"speed = %@",location.speed);
       NSLog(@"course = %@",location.course);
    
    }
    

提交回复
热议问题