File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -16,8 +16,14 @@ public class MBGeocoder: NSObject {
1616
1717 private let configuration : MBGeocoderConfiguration
1818
19- public init ( accessToken: String ) {
20- configuration = MBGeocoderConfiguration ( accessToken)
19+ /**
20+ Initializes a newly created geocoder with the given access token and an optional host.
21+
22+ - param accessToken: A Mapbox access token.
23+ - param host: An optional hostname to the server API. The Mapbox Geocoding API endpoint is used by default.
24+ */
25+ public init ( accessToken: String , host: String ? = nil ) {
26+ configuration = MBGeocoderConfiguration ( accessToken, host: host)
2127 }
2228
2329 private var task : NSURLSessionDataTask ?
Original file line number Diff line number Diff line change @@ -5,7 +5,13 @@ internal struct MBGeocoderConfiguration: Configuration {
55 internal var apiEndpoint : String = " https://api.mapbox.com "
66 internal var accessToken : String ?
77
8- internal init ( _ accessToken: String ) {
8+ internal init ( _ accessToken: String , host : String ? = nil ) {
99 self . accessToken = accessToken
10+ if let host = host {
11+ let baseURLComponents = NSURLComponents ( )
12+ baseURLComponents. scheme = " https "
13+ baseURLComponents. host = host
14+ apiEndpoint = baseURLComponents. string ?? apiEndpoint
15+ }
1016 }
1117}
You can’t perform that action at this time.
0 commit comments