2

In my application get longitude,latitude and calculate the speed.

First get the user current location longitude,latitude. Using this code got it.

[[self mapView] setShowsUserLocation:YES];
    locationManager = [[CLLocationManager alloc] init];
    [ locationManager setDelegate:self];
    // we have to setup the location manager with permission in later iOS versions
    if ([ locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
        [ locationManager requestWhenInUseAuthorization];
    }
    [ locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
     [locationManager startUpdatingLocation];


-(void) locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
    CLLocation *location = locations.lastObject;


    [[self labelLatitude] setText:[NSString stringWithFormat:@"%.6f", location.coordinate.latitude]];
    [[self labelLongitude] setText:[NSString stringWithFormat:@"%.6f", location.coordinate.longitude]];
    [[self labelAltitude] setText:[NSString stringWithFormat:@"%.2f feet", location.altitude*METERS_FEET]];

    MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(location.coordinate, 2*METERS_MILE, 2*METERS_MILE);
    [[self mapView] setRegion:viewRegion animated:YES];

}

My problem: If the user move new place means the longitude,latitude get changed successfully. How can save users current location and update the new location. and how can calculate speed. help me thanks advance.

saravanar
  • 639
  • 2
  • 11
  • 25
  • 1
    Possible duplicate of http://stackoverflow.com/questions/1391589/cllocation-speed. Speed in `CLLocation` is provided in m/s. You can just check the location.speed of your last object. – Ramon Oct 05 '16 at 10:47

0 Answers0