CLLocationCoordinate2D

CLLocationCoordinate2D

本文介绍了CLLocationCoordinate2D到CLLocation的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的viewDidLoad中的以下循环:

i have the following loop in my 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];


  }

coord是CLLocationCoordinate2D

coord is CLLocationCoordinate2D

但是如何在以下方法中使用coord,因为我需要这个来获得两个坐标之间的距离:

but how can i use coord in the following method, because i need this to get distance between two coords:

    - (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation{

}

请帮我我搁浅!

谢谢大家帮忙。

推荐答案

CLLocation - (id)initWithLatitude:(CLLocationDegrees)latitude longitude:(CLLocationDegrees)longitude
然后使用 - (CLLocationDistance)getDistanceFrom:(const CLLocation *)location 获取两个CLLocation对象之间的距离。

CLLocation has an init method named -(id)initWithLatitude:(CLLocationDegrees)latitude longitude:(CLLocationDegrees)longitude.Then use - (CLLocationDistance)getDistanceFrom:(const CLLocation *)location to get the distance between two CLLocation objects.

这篇关于CLLocationCoordinate2D到CLLocation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 10:09