0

我想在地图的左侧显示我当前的位置。

CLLocationCoordinate2D theCoordinate;
theCoordinate.latitude = 26.926;
theCoordinate.longitude = 75.8235;
MKCoordinateRegion region;
region.center = theCoordinate;
MKCoordinateSpan span;
span.latitudeDelta = 0.005;
span.longitudeDelta = 0.005;
region.span=span;
[mapView setRegion:region animated:TRUE];

由于这条线,上面的代码显示了我在地图中心的位置:

region.center = theCoordinate;

有没有办法在除中心以外的任何特定位置更改此设置?

谢谢你。

尼泰什

4

2 回答 2

0

您可以添加一种偏移量吗?

CLLocationCoordinate2D coordinatesForCenter = [theCoordinate copy];

// Add an offset :
coordinatesForCenter.latitude+=5;    // 5 for exemple (it's not significant)
coordinatesForCenter.longitude+=5;

// Center on your new coordinates :
region.center = coordinatesForCenter;

希望能帮助到你。

于 2013-05-07T13:15:18.550 回答
0

这不是特定于 Objective-C 的。如果所需位置在地图的左侧,您需要计算中心的位置。即,给定宽度为 X 的地图(以像素为单位)和比例 T,我的位置以东的点 X/2 像素的经度/纬度是多少。一旦你有了它,你可以分配

region.center = theNewCoordinate;
于 2013-05-07T13:07:37.247 回答