File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -16,8 +16,17 @@ 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+ let baseURLComponents = NSURLComponents ( )
27+ baseURLComponents. scheme = " https "
28+ baseURLComponents. host = host
29+ configuration = MBGeocoderConfiguration ( accessToken, apiEndpoint: baseURLComponents. string)
2130 }
2231
2332 private var task : NSURLSessionDataTask ?
Original file line number Diff line number Diff line change @@ -5,7 +5,8 @@ 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 , apiEndpoint : String ? = nil ) {
99 self . accessToken = accessToken
10+ self . apiEndpoint = apiEndpoint ?? self . apiEndpoint
1011 }
1112}
You can’t perform that action at this time.
0 commit comments