puntos medir mapa google geograficos geograficas entre edificios earth distancias distancia coordenadas como calcular alturas objective-c cocoa-touch core-location cllocation

objective c - mapa - ¿Cómo medir la distancia en metros entre dos CLLocations?



como medir distancias en google maps iphone (5)

¿Cómo puedo obtener la distancia en metros entre dos CLLocation ? CLLocation no proporciona ningún método para hacerlo, se ve.



+ (CLLocationDistance)distanceBetweenCoordinate:(CLLocationCoordinate2D)originCoordinate andCoordinate:(CLLocationCoordinate2D)destinationCoordinate { CLLocation *originLocation = [[CLLocation alloc] initWithLatitude:originCoordinate.latitude longitude:originCoordinate.longitude]; CLLocation *destinationLocation = [[CLLocation alloc] initWithLatitude:destinationCoordinate.latitude longitude:destinationCoordinate.longitude]; CLLocationDistance distance = [originLocation distanceFromLocation:destinationLocation]; [originLocation release]; [destinationLocation release]; return distance; }


CLLocation *loc1 = [[CLLocation alloc] initWithLatitude:dblLatitude longitude:dblLongitude]; CLLocation *loc2 = [[CLLocation alloc] initWithLatitude:dblCurrentLatitude longitude:dblCurrentLongitude]; double dMeters = [loc1 distanceFromLocation:loc2]; [loc1 release]; [loc2 release];


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 totaldistancecovered = [distanceString floatValue]; //Now,you can use this float value for addition... // distanceMoved should be float type variable which is declare in .h file... distanceMoved = distanceMoved + totaldistancecovered ; theLabel.text = [NSString stringWithFormat: @"%f meters", distanceMoved];

Espero que esto te ayudará...