Sur*_*rya 6 cocoa-touch objective-c geolocation latitude-longitude ios
我从服务器收到多家餐馆的纬度/经度.我想计算每个餐馆和用户当前纬度/经度之间的距离.
Emp*_*ack 39
您可以使用CLLocation的distanceFromLocation:方法返回两个CLLocation之间的距离(以米为单位).
CLLocation *currentLoc = /* Assume you have found it */;
CLLocation *restaurantLoc = [[CLLocation alloc] initWithLatitude:restaurantLat longitude:restaurantLng];
CLLocationDistance meters = [restaurantLoc distanceFromLocation:currentLoc];
// Go ahead with this
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9136 次 |
| 最近记录: |