MKMapView 未以图钉为中心
我有一个 mkmapview,我当前正在向其添加引脚,但由于某种原因,当我调用 [mapView setRegion:[detailItem CoditionRegion]animated:YES];
时,引脚偏离中心(朝右)屏幕一侧)在地图上。这是[deailItem坐标区域]
的代码:
- (MKCoordinateRegion)coordinateRegion {
MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
region.center = self.coordinate;
region.span.longitudeDelta = 0.0075f;
region.span.latitudeDelta = 0.0075f;
return (region);
}
我将坐标区域的中心设置为对象的x,y坐标,那么为什么它在地图上偏离中心呢?我觉得我在这里缺少一些东西......
::Val::
I have an mkmapview that i'm currently adding pins to, but for some reason when I call [mapView setRegion:[detailItem coordinateRegion] animated:YES];
the pin is off-centered (toward the right side of the screen) on the map. Here is the code for [deailItem coordinateRegion]
:
- (MKCoordinateRegion)coordinateRegion {
MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
region.center = self.coordinate;
region.span.longitudeDelta = 0.0075f;
region.span.latitudeDelta = 0.0075f;
return (region);
}
I'm setting the coordinateRegion's center to the object's x,y coordinate, so why is it off-center on the map? I feel like there's something I'm missing here...
::Val::
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
MKMapView
的界限是多少?选择注释后,您不必执行任何操作 ([mapView selectAnnotation:annotationAnimated:YES];
)。可能是您的
MKMapView
框架大于您的实际查看区域。地图居中,但视图未居中。What are your bounds for
MKMapView
? You shouldn't have to do anything after you've selected the annotation ([mapView selectAnnotation:annotation animated:YES];
).It could be that your frame for
MKMapView
is bigger than your actual viewing area. The map is centered, but the view is not.该文档讨论了垂直与水平跨度并不相同,因为一纬度不等于一经度。这种效应在两极会更加明显。应用区域后尝试使用 setCenter。有关跨度的进一步讨论,请参阅文档。
The documentation discusses this the vert vs. horizontal spans are not identical because one degree of latitude does not equal one degree of longitude. This effect will be more pronounced by the poles. Try using setCenter after you've applied the region. See the docs for further discussion of span.