문제

Each time I search for something on my mapView the map zooms to the desired location. Yet, after the first search the zoomed region is zoomed too much and continues to zoom in more with each additional search. I've tried to adding to the regions latitude and longitude delta's but it doesn't increase. I've added the code I use to zoom to the location searched. Thanks in advance.

 CLPlacemark *topResult = [placemarks objectAtIndex:0];
                             MKPlacemark *placemark = [[MKPlacemark alloc] initWithPlacemark:topResult];


                             MKCoordinateRegion region = self.mapView.region;
                             region.center = placemark.region.center;
                             region.span.longitudeDelta /= 100.0;
                             region.span.latitudeDelta /= 100.0;



                             [self.mapView setRegion:region animated:YES];
                             [self.mapView addAnnotation:placemark];



                             NSLog(@"Region span long: %f",region.span.longitudeDelta);
                             NSLog(@"Region. span lat:: %f",region.span.latitudeDelta);

                             region = self.mapView.region;
                             region.span.longitudeDelta *= 100;
                             region.span.latitudeDelta *= 100;
도움이 되었습니까?

해결책

You grab region each time from mapView and do delta /= 100, then set it to mapView again.
Your *=100 has no effect, because it is not stored anywhere after.
So this gives you effect of zomming each search)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top