只对一个城市使用 MapKit

发布于 2024-10-16 16:31:57 字数 119 浏览 2 评论 0原文

我不太确定如何在谷歌中表达这个问题,所以我会尝试在这里询问。我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

究竟谁懂我的在乎 2024-10-23 16:31:57

如果将其添加到 viewDidLoad:

MKCoordinateRegion region={{0.0,0.0,},{0,0.0}};
region.center.latitude = 30.44;
region.center.longitude = -84.31;
region.span.latitudeDelta=0.03;
region.span.longitudeDelta=0.03;
[mapView setRegion:region animated:YES]; 
[mapView setMapType:MKMapTypeStandard];
[mapView setZoomEnabled:YES];
[mapView setScrollEnabled:NO];
[mapView setDelegate:self]; 

它将以纬度和经度为中心,并由 latDelta 和 longDelta 指定放大倍数。这些值越低,缩放得越近。

if you add this to viewDidLoad:

MKCoordinateRegion region={{0.0,0.0,},{0,0.0}};
region.center.latitude = 30.44;
region.center.longitude = -84.31;
region.span.latitudeDelta=0.03;
region.span.longitudeDelta=0.03;
[mapView setRegion:region animated:YES]; 
[mapView setMapType:MKMapTypeStandard];
[mapView setZoomEnabled:YES];
[mapView setScrollEnabled:NO];
[mapView setDelegate:self]; 

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.

断肠人 2024-10-23 16:31:57

每当地图滚动时,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, use setRegion:animated: to move the map back into the correct bounds.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文