我正在尝试在纽约的一个街区周围绘制一条矩形折线。
这是我的职责。当我运行我的应用程序时,地图会显示在该区域附近,但不会显示彩色线。
func createPolyline(mapView: MKMapView) {
let point1 = CLLocationCoordinate2DMake(40.785275, -73.969286);
let point2 = CLLocationCoordinate2DMake(40.782042, -73.971743);
let point3 = CLLocationCoordinate2DMake(40.783309, -73.974565);
let point4 = CLLocationCoordinate2DMake(40.786502, -73.972194);
let point5 = CLLocationCoordinate2DMake(40.785275, -73.969286);
let points: [CLLocationCoordinate2D]
points = [point1, point2, point3, point4, point5]
let geodesic = MKGeodesicPolyline(coordinates: points, count: 5)
mapView.add(geodesic)
UIView.animate(withDuration: 1.5, animations: { () -> Void in
let span = MKCoordinateSpanMake(0.01, 0.01)
let region1 = MKCoordinateRegion(center: point1, span: span)
self.mapView.setRegion(region1, animated: true)
})
}