1

在 Xcode 的最后一个版本中,设置区域工作正常,现在在 3.2.3 中它不会捕捉到您指定的区域?

View 加载后...

 [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];

这是运行良好的代码,现在它不会捕捉到上面指出的位置,它只是显示世界地图。

非常感谢任何帮助。

4

1 回答 1

0

我在 3.2.3 和 iOS4 中做了很多。我保证它有效。

我喜欢MKCoordinateRegionMakeWithDistance()

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

第二个和第三个 arg 中的“1000, 1000”是该区域范围分量的纬度和经度米。通过 mapview 的-regionThatFits:方法传递区域只是一个好习惯。

于 2010-07-03T21:52:57.037 回答