我使用以下代码在用户位置显示 map 中心:
...
// start off by default current position
AppManager *appManager = [AppManager sharedManager];
MKCoordinateRegion newRegion;
newRegion.center.latitude = [appManager.currentlatitude floatValue];
newRegion.center.longitude = [appManager.currentlongitude floatValue];
newRegion.span.latitudeDelta = 0.06;
newRegion.span.longitudeDelta = 0.06;
[self.mapView setRegion:newRegion animated:YES];
[self.view insertSubview:mapView atIndex:0];
...
问题是,在使用“newRegion.span.latitudeDelta”和“newRegion.span.longitudeDelta”值时,我无法充分降低缩放级别。当我想要几百个时,缩放只显示大约 30 公里宽的区域。
就我所见,longitudeDelta 的值 0.06 应该显示 180 度(地球的一半)(对于纬度 0),然后对于纬度 43,我认为我应该看到超过 30 公里。
有什么想法吗?
最佳答案
latitudeDelta
和 longitudeDelta
以度为单位,因此 0.06 的值是相对较小的距离(以公里为单位)。要显示“半个地球”,您必须将 longitudeDelta
设置为 180.0。
如果您知道要显示的距离(例如以公里为单位),使用 MKCoordinateRegionMakeWithDistance
函数会更容易,而不是尝试自己进行转换:
CLLocationCoordinate2D newCenter =
CLLocationCoordinate2DMake([appManager.currentlatitude floatValue],
[appManager.currentlongitude floatValue]);
MKCoordinateRegion newRegion =
MKCoordinateRegionMakeWithDistance(newCenter, 200000, 200000);
最后两个参数是 latitudinalMeters
和 longitudinalMeters
因此上面的示例将跨度设置为 200 公里 x 200 公里。
请记住, map View 随后会根据 map View 的比例和可显示的缩放级别根据需要调整区域。
关于objective-c - 我的谷歌地图 iOS 应用中的缩放级别受到限制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8668097/