[英]iPhone MKMapView: Detecting Nearest Locations in Array from Current Location
[英]get nearest locations from my current location
我目前正在開發iOS的移動應用程序,該應用程序的一部分需要確定用戶的當前位置,並希望從當前位置確定最近的位置。
有什么辦法可以實現嗎?
我已經做了一些編碼來查找用戶的當前位置。 這是我的代碼段,
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder reverseGeocodeLocation:locationManager.location
completionHandler:^(NSArray *placemarks, NSError *error) {
NSLog(@"reverseGeocodeLocation:completionHandler: Completion Handler called!");
if (error){
NSLog(@"Geocode failed with error: %@", error);
return;
}
CLPlacemark *placemark = [placemarks objectAtIndex:0];
NSLog(@"placemarks=%@",[placemarks objectAtIndex:0]);
但是我的問題是,我將如何到達其他最近的地方? 從我已經獲取的當前位置開始。
提前致謝。
嘗試這個...
MKPointAnnotation *ann=[MKPointAnnotaion alloc] init];
CLLocationCoordinate2D point = [ann coordinate];
myLocation = [[CLLocation alloc] initWithLatitude:point.latitude longitude:point.longitude];
CLLocationDistance nearByLocation=[yourCurrentLocation distanceFromLocation:myLocation];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.