我的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,因为我需要这个来获得两个coord之间的距离:
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation{
}
请帮帮我,我被困住了!
感谢你们事前的帮助
发布于 2010-02-23 22:42:34
CLLocation
有一个名为-(id)initWithLatitude:(CLLocationDegrees)latitude longitude:(CLLocationDegrees)longitude
的初始化方法。然后使用- (CLLocationDistance)getDistanceFrom:(const CLLocation *)location
获取两个CLLocation对象之间的距离。
发布于 2014-07-19 04:49:23
简单
CLLocation *location = [[CLLocation alloc] initWithLatitude:lat longitude:lon];
发布于 2014-11-12 02:19:17
对于斯威夫特的观众,
我有一个名为"fetchCafesArroundLocation“的方法,它会在地图移动后刷新。这就是我如何将经度和经度从CLLocationCoordiate2d导入CLLocation,然后将CLLocation变量传递给处理方法。
func mapView(mapView: MKMapView!, regionDidChangeAnimated animated: Bool){
var centre = mapView.centerCoordinate as CLLocationCoordinate2D
var getLat: CLLocationDegrees = centre.latitude
var getLon: CLLocationDegrees = centre.longitude
var getMovedMapCenter: CLLocation = CLLocation(latitude: getLat, longitude: getLon)
self.lastLocation = getMovedMapCenter
self.fetchCafesAroundLocation(getMovedMapCenter)
}
https://stackoverflow.com/questions/2318547
复制相似问题