iPhone Core Location: Calculate total elevation loss/gain
问题 I am wanting to calculate total elevation loss and gain at the end of recording Core Location data. I am having a hard time thinking of the math for this one. Say if I started at 600 feet and I go up and down during the tracking, how would I calculate my elevation gain and loss? Ideas? 回答1: If you wanted to track gain and loss separately, keep two cumulative member variables, netElevationLoss and netElevationGain, both initialized to 0. - (void)locationManager:(CLLocationManager *)manager