Last active
June 23, 2016 05:38
-
-
Save mitsuse/76b0cd79b353a0c1c5abc3ba140907b1 to your computer and use it in GitHub Desktop.
A workaround for iOS 8.x, which cannnot use `q` parameter as the label of pin. (Swift 2.2)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
public func buildMapUrl( | |
latitude latitude: Double, | |
longitude: Double, | |
label: String | |
) -> NSURL? { | |
let components = NSURLComponents(string: "http://maps.apple.com/") | |
if #available(iOS 9, *) { | |
components?.queryItems = [ | |
NSURLQueryItem( | |
name: "ll", | |
value: "\(latitude),\(longitude)" | |
), | |
NSURLQueryItem(name: "q", value: label), | |
] | |
} else { | |
components?.queryItems = [ | |
NSURLQueryItem( | |
name: "q", | |
value: "\(latitude),\(longitude)" | |
), | |
] | |
} | |
return components?.URL | |
} |
Author
mitsuse
commented
Jun 23, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment