2

私は Xcode プロジェクトに取り組んでいますが、いくつかの問題があります。私のアプリでは、GPS の位置情報があり、半径 1000 メートルの範囲でタクシー サービスを利用できます。近くで最も近いサービスを見つけたいです。タクシー サービスの場所は JSON から解析されます。そのように見えます

NSNumber * latitude = [[diction objectAtIndex:13]objectAtIndex:1];
NSLog(@"lng is =>%@", latitude);
NSNumber * longitude = [[diction objectAtIndex:13]objectAtIndex:2];
NSLog(@"lat is =>%@", longitude);

さらに、私はそのような自分の場所を持っています:

[locationManager stopUpdatingLocation];
NSLog(@"latitude: %f", newLocation.coordinate.latitude);
NSLog(@"longitude: %f", newLocation.coordinate.longitude);

最も近いサービスを見つけるために、上記の緯度と経度を差し引くにはどうすればよいですか。よろしくお願いします。

4

1 に答える 1

2
 CLLocation *oldLocation = [[CLLocation alloc] initWithLatitude:[latitude floatValue] longitude:[longitude floatValue]];
    double distance = [newLocation distanceFromLocation:oldLocation];

これを使用してください、ありがとうございます。

于 2013-03-05T04:23:33.933 に答える