经度、纬度到 XY 坐标转换
我现在想知道如何在 iPhone 编程中将经度、纬度转换为其等效的 xy 坐标分量。 (我只使用 CoreLocation 编程,并且想在 iPhone 屏幕上显示一个点,而不需要任何地图)。
谢谢
I want to now how to convert longitude, latitude to its equivalent xy coordinate components in iPhone programming. (I am using only CoreLocation programming, and want to show a point on iPhone screen without any map).
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确切的转换取决于您想要显示地球的哪个部分,并且沿经度的拉伸根据纬度而变化,至少在 墨卡托。
话虽这么说,即使您不想显示实际的 MapKit 地图,创建一个 MKMapView 并将其保留在一侧。如果您设置了要在其上适当显示的区域(通过设置
region
属性),则可以使用convertCooperative:toPointToView:
将经度和纬度映射到二维屏幕位置。请注意,MKMapView 会调整您设置的区域,以便使其对给定的视口有意义(例如,如果您给它一个区域是一个短而胖的矩形,但它拥有的视图是一个高而薄的矩形,它会选择覆盖整个短胖矩形的最小区域,但形状是高细矩形),因此,如果您指定左上角是特定地理位置的区域,但该地理位置不在正好位于视图的左上角。
Well the exact conversion depends on exactly which part of the Earth you want to show, and the stretching along longitude varies according to latitude, at least in Mercator.
That being said, even if you don't want to display an actual MapKit map, it would probably be easiest to create an MKMapView and keep it to one side. If you set the area you want to display appropriately on that (by setting the
region
property), you can useconvertCoordinate:toPointToView:
to map from longitude and latitude to a 2d screen location.Note that MKMapView adjusts the region you set so as to make sense for the viewport its been given (eg, if you gave it a region that was a short fat rectangle, but the view it had was a tall thin rectangle, it'd pick the smallest region that covers the entire short fat rectangle but is the shape of a tall thin rectangle), so don't get confused if you specify a region with the top left being a particular geolocation, but then that geolocation isn't at the exact top left of the view.