मैं कई एनोटेशन मैं अपने MKMapView में जोड़ना चाहते हैं मिल गया है (यह हो सकता 0-एन आइटम, जहां n आम तौर पर लगभग 5 है)। मैं एनोटेशन जोड़ सकते हैं ठीक है, लेकिन मैं परदे पर एक ही बार में सभी एनोटेशन फिट करने के लिए नक्शा आकार बदलने के लिए चाहते हैं, और मैं ऐसा करने के तरीके यकीन नहीं है।
मैं को देखकर किया गया है -regionThatFits:, लेकिन मैं काफी यह क्या से कोई लेना देना यकीन नहीं है। मैं कुछ कोड पोस्ट दिखाने के लिए मैं अब तक क्या मिल गया है जाएगा। मुझे लगता है कि यह एक आम तौर पर काम बिल्कुल आसान हो, लेकिन मैं अब तक MapKit के साथ एक सा अभिभूत महसूस कर रहा हूँ।
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{
location = newLocation.coordinate;
//One location is obtained.. just zoom to that location
MKCoordinateRegion region;
region.center = location;
//Set Zoom level using Span
MKCoordinateSpan span;
span.latitudeDelta = 0.015;
span.longitudeDelta = 0.015;
region.span = span;
// Set the region here... but I want this to be a dynamic size
// Obviously this should be set after I've added my annotations
[mapView setRegion:region animated:YES];
// Test data, using these as annotations for now
NSArray *arr = [NSArray arrayWithObjects:@one, @two, @three, @four, nil];
float ex = 0.01;
for (NSString *s in arr) {
JBAnnotation *placemark = [[JBAnnotation alloc] initWithLat:(location.latitude + ex) lon:location.longitude];
[mapView addAnnotation:placemark];
ex = ex + 0.005;
}
// What do I do here?
[mapView setRegion:[mapView regionThatFits:region] animated:YES];
}
सूचना, यह सब होता है के रूप में मैं कोई स्थान अपडेट प्राप्त ... कि अगर यह करने के लिए एक उपयुक्त जगह है मैं नहीं जानता। यदि नहीं, तो जहां एक बेहतर जगह हो सकता है? -viewDidLoad?
अग्रिम में धन्यवाद।













