0

Here is my code:

CLLocationCoordinate2D location;
location.latitude = 50;
location.longitude = -50;
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(location, 5, 5);

region.center=location;
[mapView setShowsUserLocation:TRUE];
[mapView setDelegate:self];

[mapView setRegion:region animated:TRUE];
[mapView regionThatFits:region];
[self setView:mapView];

It will be zoomed in, but zoomed in too far. So if I change it to this:

    CLLocationCoordinate2D location;
location.latitude = 50;
location.longitude = -50;
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(location, 200, 200);

region.center=location;
[mapView setShowsUserLocation:TRUE];
[mapView setDelegate:self];

[mapView setRegion:region animated:TRUE];
[mapView regionThatFits:region];
[self setView:mapView];

It will be zoomed out all the way. Is there something I am missing?

1
  • You know that lat/long 50,-50 is in the Atlantic Ocean and that the distances are in meters?
    – user467105
    Apr 19, 2011 at 1:50

2 Answers 2

1

It was because it called the method too early in the execution. I added a viewWillLoad that will be called after it is loaded and then everything worked properly. Thanks for the help.

0

Wouldn't numbers between 5 and 200 for the 2nd and 3rd arguments of MKCoordinateRegionMakeWithDistance make the region zoomed in an intermediate amount? The docs say that those arguments are the distance in each direction to include in the region.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.