I'm wanting to have an IBAction center my mapview's region on an annotation. The annotation is added to the mapview like this:
myAnnotation *pinLoc=[[myAnnotation alloc] init];
pinLoc.coordinate = mapview.centerCoordinate;
pinLoc.title = @"Title";
pinLoc.subtitle = @"subtitle";
[mapview addAnnotation:pinLoc];
I'd like to retreive it and move the region's center like this somehow:
- (IBAction)findPin:(id)sender {
MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
region.center.latitude = pinLoc.coordinate.latitude;
region.center.longitude = pinloc.coordinate.longitude;
region.span.latitudeDelta = 0.001f;
region.span.longitudeDelta = 0.001f;
[mapview setRegion:region animated:YES];
[mapview setDelegate:self];
}
I am also looking for a way to tell if the pin is within a polygon. I've got that working using the user location, but again, I need to retrieve the pin's coordinates to get it working with the pin also.