2

I am using following codes

 MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(CLLocationCoordinate2DMake(annView.annotation.coordinate.latitude, annView.annotation.coordinate.longitude - .04), Some KM, Some KM);

 MKCoordinateRegion adjustedRegion = [self.mapView regionThatFits:viewRegion];
 [self.mapView setRegion:adjustedRegion animated:YES];

Otherway around is

MKCoordinateRegionMake(CLLocationCoordinate2DMake(annView.annotation.coordinate.latitude, annView.annotation.coordinate.longitude - .04), ADD SPAN HERE)

Both of these makes the map zoom. How is it possible that I change the Region without any zoom.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Muhammad Umar
  • 11,391
  • 21
  • 91
  • 193

2 Answers2

4

Get the current region and just change the center point.

// get current region
MKCoordinateRegion region = self.mapView.region;
// Update the center
region.center = CLLocationCoordinate2DMake(annView.annotation.coordinate.latitude, annView.annotation.coordinate.longitude - .04);
// apply the new region
self.mapView.region = region;
rmaddy
  • 314,917
  • 42
  • 532
  • 579
2

If you have a coordinate to set, use the MKMapView -setCenterCoordinate:animated: method. Animating the position change gives the user a clue about what's happened.

CLLocationCoordinate2D coordinate = annView.annotation.coordinate;
[myMapView setCenterCoordinate:coordinate animated:YES];

Also, no need to make a new coordinate, just use the one already in the annotation view.

nevan king
  • 112,709
  • 45
  • 203
  • 241