Я хочу иметь возможность обновлять регион, отображаемый в MKMapView, позволяя пользователю вводить адрес или местоположение в UIAlertView. В настоящее время у меня есть:
if (geocoder.geocoding)
[geocoder cancelGeocode];
[geocoder geocodeAddressString:[[alertView textFieldAtIndex:0] text] completionHandler:^(NSArray *placemarks, NSError *error) {
if (!error) {
NSLog(@"Found a location");
} else {
NSLog(@"Error in geocoding");
}
NSLog(@"Num found: %d", [placemarks count]);
CLPlacemark *placemark = [placemarks objectAtIndex:0];
MKCoordinateRegion region;
region.center.latitude = placemark.region.center.latitude;
region.center.longitude = placemark.region.center.longitude;
MKCoordinateSpan span;
double radius = placemark.region.radius / 1000;
NSLog(@"Radius is %f", radius);
span.latitudeDelta = radius / 112.0;
//span.longitudeDelta = ???
region.span = span;
NSLog(@"Region is %f %f %f", region.center.latitude, region.center.longitude, span.latitudeDelta);
[mapView setRegion:region animated:YES];
}];
Моя проблема в том, что я не уверен, как рассчитать дельту долготы.
region = MKCoordinateRegionMakeWithDistance(placemark.region.center, placemark.region.radius, placemark.region.radius);
. Не уверен насчет второй части вашего вопроса. - person   schedule 06.02.2012