【发布时间】:2013-12-12 23:03:17
【问题描述】:
我必须设置我的离线地图,该地图是用 tilemill 构建的,集中在一个自定义点上。尽管我没有为 MKMapView 找到像 setRegion 这样的方法来为我完成这项工作。有没有办法将区域设置为 rmmapview 地图?
【问题讨论】:
我必须设置我的离线地图,该地图是用 tilemill 构建的,集中在一个自定义点上。尽管我没有为 MKMapView 找到像 setRegion 这样的方法来为我完成这项工作。有没有办法将区域设置为 rmmapview 地图?
【问题讨论】:
我用下面的代码解决了我的问题:
CLLocationCoordinate2D centerOfMap = CLLocationCoordinate2DMake(latitude, longitude);
[mapView setCenterCoordinate:centerOfMap];
通过这种方式,我每次都能将地图集中到我想要的位置。 另外,有人可以调整地图的缩放比例,达到自己想要的效果。
【讨论】:
不,像 ios 中的区域在路线图中不可用。您可以设置约束,使用户无法滚动出您的地图:
// Constrain our map so the user can only browse through our exported map tiles
[self.mapView setConstraintsSW:CLLocationCoordinate2DMake(self.mapSrc.bottomRightOfCoverage.latitude, self.mapSrc.topLeftOfCoverage.longitude)
NE:CLLocationCoordinate2DMake(self.mapSrc.topLeftOfCoverage.latitude, self.mapSrc.bottomRightOfCoverage.longitude)];
当然还有滚动到特定位置:
[self.mapView moveToLatLong:self.currentPosition.coordinate];
【讨论】: