CLLocationCoordinate2D

CLLocationCoordinate2D

我的viewDidLoad中有以下循环:

    for(int i=1; i<[eventsArray count]; i++) {
  NSArray *componentsArray = [[eventsArray objectAtIndex:i] componentsSeparatedByString:@","];
  if([componentsArray count] >=6) {
   Koordinate *coord = [[Koordinate alloc] init];
   coord.latitude = [[componentsArray objectAtIndex:0] floatValue];
   coord.longtitude = [[componentsArray objectAtIndex:1] floatValue];
   coord.magnitude = [[componentsArray objectAtIndex:2] floatValue];
   coord.depth = [[componentsArray objectAtIndex:3] floatValue];
   coord.title = [componentsArray objectAtIndex:4];
   coord.strasse = [componentsArray objectAtIndex:5];
   coord.herkunft = [componentsArray objectAtIndex:6];
   coord.telefon = [componentsArray objectAtIndex:7];
   coord.internet = [componentsArray objectAtIndex:8];
   [eventPoints addObject:coord];


  }

坐标为CLLocationCoordinate2D

但是我如何在以下方法中使用坐标,因为我需要它来获取两个坐标之间的距离:
    - (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation{

}

请帮助我,我受困了!

谢谢大家的帮助

最佳答案

CLLocation有一个名为-(id)initWithLatitude:(CLLocationDegrees)latitude longitude:(CLLocationDegrees)longitude的初始化方法。
然后使用- (CLLocationDistance)getDistanceFrom:(const CLLocation *)location获取两个CLLocation对象之间的距离。

关于iphone - CLLocationCoordinate2D到CLLocation,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2318547/

10-11 00:46