Pergunta

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;
Foi útil?

Solução

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)

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top