设置地图的默认位置,以开始 - iOS [英] Set a default location for the map to start at - iOS
本文介绍了设置地图的默认位置,以开始 - iOS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何设置地图的默认位置?例如,如果我想在爱尔兰设置它,我该怎么办?它目前默认为北美洲,但我希望它默认为某个坐标。
How do you set a default location for the map to start at? If I want to set it in Ireland for example, how would I do that? It currently defaults to around North America but I want it to default to a certain coordinates.
推荐答案
以下代码将位置设置为SFO 。更改坐标到您需要设置所需的位置。
The below code sets location to SFO. Change coordinates to your needs to set desired locations.
MKCoordinateRegion region = [mapView regionThatFits:MKCoordinateRegionMakeWithDistance(CLLocationCoordinate2DMake(37.78275123, -122.40345442), 200, 200)];
[mapView setRegion:region animated:YES];
如果您要查找用户的当前位置,请使用以下代码。
If you are looking for user's current location, use below code.
MKCoordinateRegion region = [mapView regionThatFits:MKCoordinateRegionMakeWithDistance(mapView.userLocation.coordinate, 200, 200)];
[mapView setRegion:region animated:YES];
这篇关于设置地图的默认位置,以开始 - iOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文