MKMapView centerCoordinate (CLLocationCoordinate2D) नामक गुण और क्षेत्र (MKCoordinateRegion) है।
typedef struct {
CLLocationDegrees latitudeDelta;
CLLocationDegrees longitudeDelta;
}MKCoordinateSpan
आप एक अन्य बिंदु, centerCoordinate के आधार पर बनाने के लिए सक्षम होना चाहिए, के लिए आप संपत्ति या centerCoordinate अक्षांश मान लीजिए कि, latitudeDelta जोड़कर, और CLLocation की विधि का उपयोग कर दूरी की गणना:
क्षेत्र एक struct कि है
- (CLLocationDistance)distanceFromLocation:(const CLLocation *)location
कुछ इस
MkMapView * mapView; // init somewhere
MKCoordinateRegion region = mapView.region;
CLLocationCoordinate2D centerCoordinate = mapView.centerCoordinate;
CLLocation * newLocation = [[[CLLocation alloc] initWithLatitude:centerCoordinate.latitude+region.span.latitudeDelta longitude:centerCoordinate.longitude] autorelease];
CLLocation * centerLocation = [[[CLLocation alloc] initWithLatitude:centerCoordinate.latitude:longitude:centerCoordinate.longitude] autorelease];
CLLocationDistance distance = [centerLocation distanceFromLocation:newLocation]; // in meters
और बस हर बार एक प्रतिनिधि एक निश्चित विधि (तय है जो आप की जरूरत है आग की गणना की तरह: MKMapViewDelegate)
यह एक बढ़िया जवाब है। – sudo
महान जवाब! आपका बहुत बहुत धन्यवाद! – Andres
'centerCoordinate.latitude + region.span.latitudeDelta' को सही त्रिज्या प्राप्त करने के लिए' centerCoordinate.latitude + region.span.latitudeDelta/2' होना चाहिए। –