【发布时间】:2016-09-13 13:51:19
【问题描述】:
我的地图上有一个注释显示一个营业地点和一个显示获取路线的按钮,我正在努力获取为我打开 Apple 地图的按钮,其中包含到注释位置的路线。这是我到目前为止所做的代码:
import UIKit
import MapKit
class FourthViewController: UIViewController , MKMapViewDelegate {
@IBOutlet weak var map: MKMapView!
override func viewDidLoad() {
super.viewDidLoad()
let latitude: CLLocationDegrees = 54.647115
let longitude: CLLocationDegrees = -6.659070
let lanDelta: CLLocationDegrees = 0.05
let lonDelta: CLLocationDegrees = 0.05
let span = MKCoordinateSpan(latitudeDelta: lanDelta, longitudeDelta: lonDelta)
let coordinates = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
let region = MKCoordinateRegion(center: coordinates, span: span)
map.setRegion(region, animated: true)
let annotation = MKPointAnnotation()
annotation.title = "Pose Beauty Salon"
annotation.subtitle = "100 Moneyhaw Road"
annotation.coordinate = coordinates
map.addAnnotation(annotation)
}
@IBAction func mapType(_ sender: AnyObject) {
switch (sender.selectedSegmentIndex) {
case 0:
map.mapType = .standard
case 1:
map.mapType = .satellite
default: // or case 2
map.mapType = .hybrid
}
}
@IBAction func getDirections(_ sender: AnyObject) {
}
}
我还看到单击时显示更多信息的注释,例如公司名称、地址、电话号码和 URL,这也很难添加吗?
【问题讨论】:
标签: ios swift3 ios10 apple-maps