【发布时间】:2018-12-21 12:57:36
【问题描述】:
我使用 Apple 的 MapKit 和 MKMapView 在屏幕上显示位置。我正在使用的功能是:
func displayLocation() {
locationMap.setRegion(MKCoordinateRegion(center: CLLocationCoordinate2DMake(userConnected.siteConnectedLat!, userConnected.siteConnectedLong!), span: MKCoordinateSpanMake(0.05, 0.05)), animated: true)
let locationPin = CLLocationCoordinate2D(latitude: userConnected.siteConnectedLat!, longitude: userConnected.siteConnectedLong!)
let annotation = MKPointAnnotation()
annotation.coordinate = locationPin
locationMap.addAnnotation(annotation)
locationMap.showAnnotations([annotation], animated: true)
}
然后在 View Controller 的 viewDidLoad 方法中调用 Is。苹果的文档说跨度应该改变缩放,但即使改变跨度也会对地图产生最小的影响。我希望它被缩小到足够的程度,以便我们可以清楚地看到 3-4 个欧洲国家,即大量的缩小。
【问题讨论】:
-
尝试跨度 (5, 5)。您当前的跨度可能太小。
-
不工作。也许我的地图大小是个问题?我在原始问题中添加了地图大小的图像。
-
它什么都没做吗?然后尝试将区域设置为
viewDIdAppear。 -
在 viewDidAppear 中添加它就像一个魅力!请将其发布为答案,以便我接受。