【问题标题】:RMMapView map set regionRMMapView 地图设置区域
【发布时间】:2013-12-12 23:03:17
【问题描述】:

我必须设置我的离线地图,该地图是用 tilemill 构建的,集中在一个自定义点上。尽管我没有为 MKMapView 找到像 setRegion 这样的方法来为我完成这项工作。有没有办法将区域设置为 rmmapview 地图?

【问题讨论】:

    标签: ios map region mapbox


    【解决方案1】:

    我用下面的代码解决了我的问题:

    CLLocationCoordinate2D centerOfMap = CLLocationCoordinate2DMake(latitude, longitude);
    
    [mapView setCenterCoordinate:centerOfMap];
    

    通过这种方式,我每次都能将地图集中到我想要的位置。 另外,有人可以调整地图的缩放比例,达到自己想要的效果。

    【讨论】:

      【解决方案2】:

      不,像 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];
      

      【讨论】:

      • moveToLatLong 方法根据编译器不存在。这是我必须自己制作的方法吗?此外,当我调用 setConstraintsSW 方法时,我得到错误的内存访问错误。
      • 我在 ios6 上使用它,不知道它是否适用于当前的 ios/xcode 版本。我在 RMMapView 头文件中有 moveToLatLong 方法定义。你用过github.com/route-me/route-me的库吗?
      • 它已通过 MapBox API 更改为 moveToCoordinate 方法,并包含在 RMShape.h 中。我要检查这个库,我会通知你。
      猜你喜欢
      • 2020-02-20
      • 1970-01-01
      • 2020-02-09
      • 1970-01-01
      • 1970-01-01
      • 2023-03-28
      • 1970-01-01
      • 1970-01-01
      • 2017-08-02
      相关资源
      最近更新 更多