MapManagerMapKit 封装器
Map manager 是 MapKit 封装器,提供路线方向绘制,完全使用 Swift 编写。
简单示例——使用 Apple 设备定向:
var latOrigin = 37.331789 var lngOrigin = -122.029620 var coordinateOrigin = CLLocationCoordinate2D(latitude: latOrigin, longitude: lngOrigin) var latDestination = 37.231789 var lngDestination = -122.029620 var coordinateDestination = CLLocationCoordinate2D(latitude: latDestination, longitude: lngDestination) mapManager.directions(from: coordinateOrigin, to: coordinateDestination) { (route, directionInformation, boundingRegion, error) -> () in if (error? != nil) { println(error!) }else{ if let web = self.mapView?{ dispatch_async(dispatch_get_main_queue()) { web.addOverlay(route!) web.setVisibleMapRect(boundingRegion!, animated: true) } } } }
评论