Tengo un MAPview que amplía la imagen a la ubicación actual utilizando viewDidLoad
:/zoom a la función actual ubicación (MapKit)
#define METERS_PER_MILE 1609.344
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
[super viewDidLoad];
mapView.showsUserLocation=TRUE;
// zoom to a specific area
CLLocationCoordinate2D zoomLocation;
zoomLocation.latitude = -28.994167;
zoomLocation.longitude = 134.866944;
MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(zoomLocation, 1900*METERS_PER_MILE, 1900*METERS_PER_MILE);
MKCoordinateRegion adjustedRegion = [mapView regionThatFits:viewRegion];
// make sure the Google water mark is always visible
mapView.autoresizingMask =
(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
[mapView setRegion:adjustedRegion animated:YES];
mapView.delegate=self;
searchBar.delegate = self;
}
Esto funciona bien. Agregué una barra de búsqueda y una función para saltar a una ubicación de dirección específica. Esto funciona bien, también. Ahora quiero agregar un botón para volver a la ubicación actual. ¿Puedes darme una mano, por favor?
Saludos
hay una función llamada setCenter? – carbonr
@carbonr sí, hay –
[mapView setCenterCoordinate: mapView.userLocation.location.coordinate animado: YES]; – carbonr