计算地图框中的角点

时间:2014-02-03 12:30:43

标签: ios iphone mapbox

在我的项目中,我在地图上绘制了一些注释。为此,我需要知道地图的四个角。所以,我想知道是否有一种简单的方法可以找到当前显示的可见矩形地图。这可以通过以下方式在原生地图中实现:

MKMapRect mRect = self.mapView.visibleMapRect;
MKMapPoint neMapPoint = MKMapPointMake(MKMapRectGetMaxX(mRect), mRect.origin.y);
MKMapPoint swMapPoint = MKMapPointMake(mRect.origin.x, MKMapRectGetMaxY(mRect)); MKMapPoint nwMapPoint = MKMapPointMake(mRect.origin.x, mRect.origin.y);
MKMapPoint seMapPoint = MKMapPointMake(MKMapRectGetMaxX(mRect), MKMapRectGetMaxY(mRect));

对于Mapbox,我考虑使用projectedBounds并使用以下代码来获取角点:

RMProjectedPoint neMapBoxPoint = RMProjectedPointMake(rect.size.width, rect.origin.y);
RMProjectedPoint swMapBoxPoint = RMProjectedPointMake(rect.origin.x, rect.size.height);
RMProjectedPoint nwMapBoxPoint = RMProjectedPointMake(rect.origin.x, rect.origin.y);
RMProjectedPoint seMapBoxPoint = RMProjectedPointMake(rect.size.width, rect.size.height);

但是,对于这两种情况,角点都不同,在地图框中,我得到了错误的数据。任何想法如何做到这一点。任何帮助,将不胜感激。

1 个答案:

答案 0 :(得分:1)

看看-[RMMapView latitudeLongitudeBoundingBox]