只对一个城市使用 MapKit
我不太确定如何在谷歌中表达这个问题,所以我会尝试在这里询问。我正在尝试使用 MapKit 在地图上显示仅一个城市的不同路线。有没有办法限制 API 中可以使用的世界地图数量?
任何建议表示赞赏。
I am not really too sure how to word this into google, so I will attempt to ask it here. I am attempting to use the MapKit to display different routes on a map for only one city. Is there a way to limit the amount of the World Map that can be used in the API?
Any suggestions are appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果将其添加到 viewDidLoad:
它将以纬度和经度为中心,并由 latDelta 和 longDelta 指定放大倍数。这些值越低,缩放得越近。
if you add this to viewDidLoad:
it will center around the lat and long, with the magnification specified by the latDelta and longDelta. The lower those values are, the closer you will be zoomed.
每当地图滚动时,
MKMapView
都会通知其委托(通过委托方法-mapView:regionWillChangeAnimated:
和–mapView:regionDidChangeAnimated:
)。也许您可以在这些方法中编写一些代码来检查用户是否已滚动到城市之外,如果是,请使用 setRegion:animated: 将地图移回正确的边界。MKMapView
will notify its delegate whenever the map is scrolled (via delegate methods-mapView:regionWillChangeAnimated:
and– mapView:regionDidChangeAnimated:
). Perhaps you could write some code in those methods to check and see whether the user has scrolled outside of the city, and if so, usesetRegion:animated:
to move the map back into the correct bounds.