views:

35

answers:

1

In the last version of Xcode, set region worked fine, now in 3.2.3 it doesn't snap to your specified region?

After View did load...

 [mapView setMapType:MKMapTypeHybrid];
 [mapView setZoomEnabled:YES];
 [mapView setScrollEnabled:YES];

 MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
 region.center.latitude = 41.902245099708516;
 region.center.longitude = 12.457906007766724;
 region.span.longitudeDelta = 0.04f;
 region.span.latitudeDelta = 0.04f; 
 [mapView setRegion:region animated:YES];

 [mapView setDelegate:self];

This is the code that worked fine, now it doesn't snap to the location denoted above, it just shows the world map.

Any help greatly appreciated.

A: 

I've done it lots in 3.2.3 and iOS4. I promise it works.

I like MKCoordinateRegionMakeWithDistance().

CLLocationCoordinate2d coord = { 41.902245099708516, 12.457906007766724 };
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(coord, 1000, 1000);
[mapView setRegion:[mapView regionThatFits:region] animated:YES];

That "1000, 1000" in the second and third arg are the latitudinal and longitudinal meters of the range component of the region. Passing the region through the mapview's -regionThatFits: method is just good practice.

Dan Ray