import CoreLocation
// 参考サイト
// - Map Links: https://developer.apple.com/library/ios/featuredarticles/iPhoneURLScheme_Reference/MapLinks/MapLinks.html
//
class MapLinkUtils {
// 目的地周辺の地図を表示する
class func showLocation(location: CLLocation, address: String) {
let daddr = NSString(format: "%f,%f", location.coordinate.latitude, location.coordinate.longitude)
let urlString = "http://maps.apple.com/?ll=\(daddr)&address=\(address)"
print(urlString)
let encodedUrl = urlString.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet())!
let url = NSURL(string: encodedUrl)!
UIApplication.sharedApplication().openURL(url)
}
// 経路情報を表示する
class func showNavigation(srcLocation: CLLocation, destLocation: CLLocation, address: String) {
let saddr = NSString(format: "%f,%f", srcLocation.coordinate.latitude, srcLocation.coordinate.longitude)
let daddr = NSString(format: "%f,%f", destLocation.coordinate.latitude, destLocation.coordinate.longitude)
let urlString = "http://maps.apple.com/?saddr=\(saddr)&daddr=\(daddr)&dirflg=d&q=\(address)"
print(urlString)
let encodedUrl = urlString.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet())!
let url = NSURL(string: encodedUrl)!
UIApplication.sharedApplication().openURL(url)
}
}