作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我只是重写 MKOverlay,所以我正在 Apple 开发人员示例代码中寻找良好的实践......当我看到这个时:
// bite off up to 1/4 of the world to draw into.
MKMapPoint origin = points[0];
origin.x -= MKMapSizeWorld.width / 8.0;
origin.y -= MKMapSizeWorld.height / 8.0;
MKMapSize size = MKMapSizeWorld;
size.width /= 4.0;
size.height /= 4.0;
boundingMapRect = (MKMapRect) { origin, size };
MKMapRect worldRect = MKMapRectMake(0, 0, MKMapSizeWorld.width, MKMapSizeWorld.height);
boundingMapRect = MKMapRectIntersection(boundingMapRect, worldRect);
问候,
编辑
所以我只能这样做?
// set the smallest rectangle which able to contain this overlay
MKMapPoint leftTopPoint = MKMapPointForCoordinate(leftTopCorner);
MKMapPoint rightBottomPoint = MKMapPointForCoordinate([self bottomRightCoord]);
boundingMapRect = MKMapRectMake(leftTopPoint.x, leftTopPoint.y,
fabs(leftTopPoint.x - rightBottomPoint.x),
fabs(leftTopPoint.y - rightBottomPoint.y));
最佳答案
该代码来自面包屑示例,与大多数覆盖层相比,它可能有点不寻常,因为它是动态更新的。他们实际上将边界区域设置为世界区域的四分之一,这本身就有点不寻常,通常您会期望它小得多。我认为交集只是为了确保生成的矩形绝对位于整个世界矩形内。我不确定是否会推荐此代码作为最佳实践,除非您正在做类似的事情(即创建动态覆盖)。如果您在不间断地环游世界,或者甚至只是跨越国际日期变更线时运行面包屑应用程序,那么大概甚至可以捕获此代码......
关于iphone - 为什么苹果这样做: MKMapRectIntersection(boundingMapRect, worldRect)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15705473/
我只是重写 MKOverlay,所以我正在 Apple 开发人员示例代码中寻找良好的实践......当我看到这个时: // bite off up to 1/4 of the world to
我是一名优秀的程序员,十分优秀!