MKMapView:缩放至默认“国家级别" [英] MKMapView: Zoom to default "country level"

查看:69
本文介绍了MKMapView:缩放至默认“国家级别"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将 MKMapView 放入 UIViewController 并将其设置为卫星视图时,地图会缩放并调整以显示用户当前所在的整个国家/地区:例如美国,如下所示.

when putting a MKMapView into a UIViewController and setting it to Satellite view, the map is zoomed and adjusted to show the whole country the user is current located in: For example the United States as shown below.

当用户现在缩放地图或我以编程方式缩放地图时,它似乎无法恢复此默认缩放级别.

When the user is now zooming the map or I'm zooming the map programmatically, it doesn't seem to be able to restore this default zoom level.

当然我可以找出这个默认缩放的坐标以便缩放回那个设置,但实际上我需要为每个不值得的国家/地区都这样做.

Of course I could find out the coordinates of this default zoom in order to zoom back to that setting, but practically I would need to do that for every single country which isn't really worth it.

有人知道如何解决这个问题吗?

Does someone know how to solve this problem?

推荐答案

为此,它需要两种类型的信息.所选国家/地区的中心坐标以及为地图上的 region.span 设置的正确值.它可能可以访问 Apple Maps 数据库中的数据.我不知道这会向我们公开.但是,如果您四处搜索,互联网上还有其他地理编码数据库可能会给您这两个值.

To do that, it needs two types of information. The center coordinates for the selected country and the correct value to set for region.span on the map. It likely has access to that data from the Apple Maps database. I am not aware of that being made public to us. But there are other geocoding databases out there on the internet if you search around that might give you those two values.

如果你找到一个有你想要的东西,那么你可以在地图上使用:

If you find one that has what you want, then you set it on the map using:

myMKMapView.region.center = // Center coordinates of country
myMKMapView.region.span = // A value large enough to enclose the country.

这篇关于MKMapView:缩放至默认“国家级别"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆