-
Notifications
You must be signed in to change notification settings - Fork 313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Map labels are no longer blank and using China Map Style URLs if the application is configured to use Mapbox China APIs #1558
Changes from 2 commits
34f90ac
cc9286a
87bfdea
d681921
d3664e5
2ee884c
f701580
3688c3b
d59a428
a064cc8
cfe9473
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Foundation | ||
import Mapbox | ||
|
||
|
||
extension MGLAccountManager{ | ||
|
||
static let mapboxChinaBaseAPIURL = "https://api.mapbox.cn" | ||
static let mapboxChinaBaseURLHost = "api.mapbox.cn" | ||
static let mapboxChinaDayStyleURL = "mapbox://styles/mapbox/streets-zh-v1" | ||
static let mapboxChinaNightStyleURL = "mapbox://styles/mapbox/dark-zh-v1" | ||
|
||
// Value of whether the map is China map or not | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the |
||
public class var hasChinaBaseURL : Bool{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is public, let’s make it available to Objective-C code using |
||
let apiBaseURL = Bundle.main.object(forInfoDictionaryKey:"MGLMapboxAPIBaseURL") as? String | ||
return apiBaseURL == mapboxChinaBaseAPIURL | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,26 @@ | ||
import Foundation | ||
import Mapbox | ||
|
||
|
||
extension MGLStyle { | ||
// Returns the URL to the current version of the Mapbox Navigation Guidance Day style. | ||
@objc | ||
public class var navigationGuidanceDayStyleURL: URL { get { return URL(string: "mapbox://styles/mapbox/navigation-guidance-day-v2")! } } | ||
public class var navigationGuidanceDayStyleURL: URL { get { return URL(string: (MGLAccountManager.hasChinaBaseURL ? MGLAccountManager.mapboxChinaDayStyleURL : "mapbox://styles/mapbox/navigation-guidance-day-v2"))! } } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with using constants for the China URLs since each gets reused. However, consider turning them into URL-typed static constants within MGLStyle. (There’s no need for string constants if we have constant URLs.) extension MGLStyle {
static let streetsChineseURL = URL(string: "mapbox://styles/mapbox/streets-zh-v1")!
} |
||
|
||
// Returns the URL to the current version of the Mapbox Navigation Guidance Night style. | ||
@objc | ||
public class var navigationGuidanceNightStyleURL: URL { get { return URL(string: "mapbox://styles/mapbox/navigation-guidance-night-v2")! } } | ||
public class var navigationGuidanceNightStyleURL: URL { get { return URL(string: (MGLAccountManager.hasChinaBaseURL ? MGLAccountManager.mapboxChinaNightStyleURL : "mapbox://styles/mapbox/navigation-guidance-night-v2"))! } } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For readability, put this code on multiple lines instead of using a ternary operator. (×4) |
||
|
||
@objc | ||
// Returns the URL to the given version of the navigation guidance style. Available version are 1, 2, and 3. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a note that the version is ignored when the API base URL is api.mapbox.cn. (×2) Also, while you’re here, would you mind turning all four of these comments into proper documentation comments using the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure. |
||
public class func navigationGuidanceDayStyleURL(version: Int) -> URL { | ||
return URL(string: "mapbox://styles/mapbox/navigation-guidance-day-v\(version)")! | ||
return URL(string: (MGLAccountManager.hasChinaBaseURL ? MGLAccountManager.mapboxChinaDayStyleURL :"mapbox://styles/mapbox/navigation-guidance-day-v\(version)"))! | ||
} | ||
|
||
@objc | ||
|
||
// Returns the URL to the given version of the navigation guidance style. Available version are 2, and 3. | ||
public class func navigationGuidanceNightStyleURL(version: Int) -> URL { | ||
return URL(string: "mapbox://styles/mapbox/navigation-guidance-night-v\(version)")! | ||
return URL(string: (MGLAccountManager.hasChinaBaseURL ? MGLAccountManager.mapboxChinaNightStyleURL :"mapbox://styles/mapbox/navigation-guidance-night-v\(version)"))! | ||
} | ||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move the style URLs to the MGLStyle extension?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually u r right. I'll modify that.