From 34f90ac5a71e1de08e5e0a3345849f66515d060b Mon Sep 17 00:00:00 2001 From: "M.Stephen" Date: Mon, 16 Jul 2018 15:16:46 +0800 Subject: [PATCH 01/11] Solution for issue#https://github.com/mapbox/mapbox-navigation-ios/issues/1554 --- MapboxNavigation.xcodeproj/project.pbxproj | 4 +++ MapboxNavigation/NavigationMapView.swift | 4 +++ MapboxNavigation/NetworkConfiguartion.swift | 31 +++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 MapboxNavigation/NetworkConfiguartion.swift diff --git a/MapboxNavigation.xcodeproj/project.pbxproj b/MapboxNavigation.xcodeproj/project.pbxproj index 660b4c29b6..fa8b7760ca 100644 --- a/MapboxNavigation.xcodeproj/project.pbxproj +++ b/MapboxNavigation.xcodeproj/project.pbxproj @@ -251,6 +251,7 @@ C5EF397520599120009A2C50 /* straight-line.json in Resources */ = {isa = PBXBuildFile; fileRef = C5EF397420599120009A2C50 /* straight-line.json */; }; C5F2DCA0206DBF5E002F99F6 /* Sequence.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5F2DC9F206DBF5E002F99F6 /* Sequence.swift */; }; C5F2DCA1206DBF5E002F99F6 /* Sequence.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5F2DC9F206DBF5E002F99F6 /* Sequence.swift */; }; + CFD47D8C20FC7D5E00BC1E49 /* NetworkConfiguartion.swift in Sources */ = {isa = PBXBuildFile; fileRef = CFD47D8B20FC7D5E00BC1E49 /* NetworkConfiguartion.swift */; }; DA23C9611F4FC05C00BA9522 /* MGLMapView+MGLNavigationAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 35D825F91E6A2DBE0088F83B /* MGLMapView+MGLNavigationAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; }; DA3525702010A5210048DDFC /* Localizable.stringsdict in Resources */ = {isa = PBXBuildFile; fileRef = DA35256E2010A5200048DDFC /* Localizable.stringsdict */; }; DAAE5F301EAE4C4700832871 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = DAAE5F321EAE4C4700832871 /* Localizable.strings */; }; @@ -663,6 +664,7 @@ C5E7A31B1F4F6828001CB015 /* NavigationRouteOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationRouteOptions.swift; sourceTree = ""; }; C5EF397420599120009A2C50 /* straight-line.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "straight-line.json"; sourceTree = ""; }; C5F2DC9F206DBF5E002F99F6 /* Sequence.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Sequence.swift; sourceTree = ""; }; + CFD47D8B20FC7D5E00BC1E49 /* NetworkConfiguartion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkConfiguartion.swift; sourceTree = ""; }; DA1811FD20128B0900C91918 /* he */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = he; path = he.lproj/Main.strings; sourceTree = ""; }; DA1811FE20128B0900C91918 /* he */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = he; path = he.lproj/Navigation.strings; sourceTree = ""; }; DA18120120128B7B00C91918 /* he */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = he; path = he.lproj/Localizable.strings; sourceTree = ""; }; @@ -915,6 +917,7 @@ 356B7D8A1EE166E100FE5B89 /* scripts */, 351BEC201E5BD4DC006FE110 /* Supporting files */, C51923B51EA55CD4002AF9E1 /* Views */, + CFD47D8B20FC7D5E00BC1E49 /* NetworkConfiguartion.swift */, 3EA93A10227A7DAF1861D9F5 /* Cache.swift */, 160D8278205996DA00D278D6 /* DataCache.swift */, 35726EE71F0856E900AFA1B6 /* DayStyle.swift */, @@ -1856,6 +1859,7 @@ 35ECAF2D2092275100DC3BC3 /* UIImage.swift in Sources */, 351BEC051E5BCC6C006FE110 /* LaneView.swift in Sources */, C5A7EC5C1FD610A80008B9BA /* VisualInstructionComponent.swift in Sources */, + CFD47D8C20FC7D5E00BC1E49 /* NetworkConfiguartion.swift in Sources */, 351BEC0D1E5BCC72006FE110 /* Bundle.swift in Sources */, 8DF399B21FB257B30034904C /* UIGestureRecognizer.swift in Sources */, 35B7837E1F9547B300291F9A /* Transitioning.swift in Sources */, diff --git a/MapboxNavigation/NavigationMapView.swift b/MapboxNavigation/NavigationMapView.swift index d33c1ee3c9..51dec2c2da 100644 --- a/MapboxNavigation/NavigationMapView.swift +++ b/MapboxNavigation/NavigationMapView.swift @@ -946,6 +946,10 @@ open class NavigationMapView: MGLMapView, UIGestureRecognizerDelegate { to call this method on the value of `NavigationViewController.mapView`. */ @objc public func localizeLabels() { + if(NetworkConfiguration.sharedConfiguration.isChinaMap()){ + return + } + guard let style = style else { return } diff --git a/MapboxNavigation/NetworkConfiguartion.swift b/MapboxNavigation/NetworkConfiguartion.swift new file mode 100644 index 0000000000..04f924caeb --- /dev/null +++ b/MapboxNavigation/NetworkConfiguartion.swift @@ -0,0 +1,31 @@ +import Foundation + +class NetworkConfiguration : NSObject{ + @objc static let sharedConfiguration = NetworkConfiguration() + + // The current API base URL of map + private var apiBaseURL : String? + + // The PRC base URL for Mapbox APIs other than the telemetry API. + private let mapboxChinaBaseAPIURL = "https://api.mapbox.cn" + + // The base URL host for Mapbox China + public let mapboxChinaBaseURLHost = "api.mapbox.cn" + + // The URL String of China map style. + public let mapboxChinaStyleURL = "mapbox://styles/mapbox/streets-zh-v1" + + private override init() { + super.init() + apiBaseURL = Bundle.main.object(forInfoDictionaryKey:"MGLMapboxAPIBaseURL") as? String + } + + // Return of whether the map is China map or not + public func isChinaMap() -> Bool{ + guard apiBaseURL != nil, apiBaseURL == mapboxChinaBaseAPIURL else { + return false + } + return true + } + +} From cc9286ad79995ab5839df937c866be14c710ee36 Mon Sep 17 00:00:00 2001 From: "M.Stephen" Date: Tue, 17 Jul 2018 10:05:28 +0800 Subject: [PATCH 02/11] Modify for #PR https://github.com/mapbox/mapbox-navigation-ios/pull/1558 --- MapboxNavigation.xcodeproj/project.pbxproj | 8 ++++---- MapboxNavigation/NavigationMapView.swift | 2 +- MapboxNavigation/NetworkConfiguartion.swift | 16 ++++++++-------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/MapboxNavigation.xcodeproj/project.pbxproj b/MapboxNavigation.xcodeproj/project.pbxproj index fa8b7760ca..52525b1e08 100644 --- a/MapboxNavigation.xcodeproj/project.pbxproj +++ b/MapboxNavigation.xcodeproj/project.pbxproj @@ -251,7 +251,7 @@ C5EF397520599120009A2C50 /* straight-line.json in Resources */ = {isa = PBXBuildFile; fileRef = C5EF397420599120009A2C50 /* straight-line.json */; }; C5F2DCA0206DBF5E002F99F6 /* Sequence.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5F2DC9F206DBF5E002F99F6 /* Sequence.swift */; }; C5F2DCA1206DBF5E002F99F6 /* Sequence.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5F2DC9F206DBF5E002F99F6 /* Sequence.swift */; }; - CFD47D8C20FC7D5E00BC1E49 /* NetworkConfiguartion.swift in Sources */ = {isa = PBXBuildFile; fileRef = CFD47D8B20FC7D5E00BC1E49 /* NetworkConfiguartion.swift */; }; + CFD47D9020FD85EC00BC1E49 /* NetworkConfiguartion.swift in Sources */ = {isa = PBXBuildFile; fileRef = CFD47D8F20FD85EC00BC1E49 /* NetworkConfiguartion.swift */; }; DA23C9611F4FC05C00BA9522 /* MGLMapView+MGLNavigationAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 35D825F91E6A2DBE0088F83B /* MGLMapView+MGLNavigationAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; }; DA3525702010A5210048DDFC /* Localizable.stringsdict in Resources */ = {isa = PBXBuildFile; fileRef = DA35256E2010A5200048DDFC /* Localizable.stringsdict */; }; DAAE5F301EAE4C4700832871 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = DAAE5F321EAE4C4700832871 /* Localizable.strings */; }; @@ -664,7 +664,7 @@ C5E7A31B1F4F6828001CB015 /* NavigationRouteOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationRouteOptions.swift; sourceTree = ""; }; C5EF397420599120009A2C50 /* straight-line.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "straight-line.json"; sourceTree = ""; }; C5F2DC9F206DBF5E002F99F6 /* Sequence.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Sequence.swift; sourceTree = ""; }; - CFD47D8B20FC7D5E00BC1E49 /* NetworkConfiguartion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkConfiguartion.swift; sourceTree = ""; }; + CFD47D8F20FD85EC00BC1E49 /* NetworkConfiguartion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkConfiguartion.swift; sourceTree = ""; }; DA1811FD20128B0900C91918 /* he */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = he; path = he.lproj/Main.strings; sourceTree = ""; }; DA1811FE20128B0900C91918 /* he */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = he; path = he.lproj/Navigation.strings; sourceTree = ""; }; DA18120120128B7B00C91918 /* he */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = he; path = he.lproj/Localizable.strings; sourceTree = ""; }; @@ -917,7 +917,7 @@ 356B7D8A1EE166E100FE5B89 /* scripts */, 351BEC201E5BD4DC006FE110 /* Supporting files */, C51923B51EA55CD4002AF9E1 /* Views */, - CFD47D8B20FC7D5E00BC1E49 /* NetworkConfiguartion.swift */, + CFD47D8F20FD85EC00BC1E49 /* NetworkConfiguartion.swift */, 3EA93A10227A7DAF1861D9F5 /* Cache.swift */, 160D8278205996DA00D278D6 /* DataCache.swift */, 35726EE71F0856E900AFA1B6 /* DayStyle.swift */, @@ -1859,7 +1859,7 @@ 35ECAF2D2092275100DC3BC3 /* UIImage.swift in Sources */, 351BEC051E5BCC6C006FE110 /* LaneView.swift in Sources */, C5A7EC5C1FD610A80008B9BA /* VisualInstructionComponent.swift in Sources */, - CFD47D8C20FC7D5E00BC1E49 /* NetworkConfiguartion.swift in Sources */, + CFD47D9020FD85EC00BC1E49 /* NetworkConfiguartion.swift in Sources */, 351BEC0D1E5BCC72006FE110 /* Bundle.swift in Sources */, 8DF399B21FB257B30034904C /* UIGestureRecognizer.swift in Sources */, 35B7837E1F9547B300291F9A /* Transitioning.swift in Sources */, diff --git a/MapboxNavigation/NavigationMapView.swift b/MapboxNavigation/NavigationMapView.swift index 51dec2c2da..882de00cef 100644 --- a/MapboxNavigation/NavigationMapView.swift +++ b/MapboxNavigation/NavigationMapView.swift @@ -946,7 +946,7 @@ open class NavigationMapView: MGLMapView, UIGestureRecognizerDelegate { to call this method on the value of `NavigationViewController.mapView`. */ @objc public func localizeLabels() { - if(NetworkConfiguration.sharedConfiguration.isChinaMap()){ + guard NetworkConfiguration.sharedConfiguration.isChinaMap == false else{ return } diff --git a/MapboxNavigation/NetworkConfiguartion.swift b/MapboxNavigation/NetworkConfiguartion.swift index 04f924caeb..92c88c14d7 100644 --- a/MapboxNavigation/NetworkConfiguartion.swift +++ b/MapboxNavigation/NetworkConfiguartion.swift @@ -15,17 +15,17 @@ class NetworkConfiguration : NSObject{ // The URL String of China map style. public let mapboxChinaStyleURL = "mapbox://styles/mapbox/streets-zh-v1" - private override init() { - super.init() - apiBaseURL = Bundle.main.object(forInfoDictionaryKey:"MGLMapboxAPIBaseURL") as? String - } - - // Return of whether the map is China map or not - public func isChinaMap() -> Bool{ - guard apiBaseURL != nil, apiBaseURL == mapboxChinaBaseAPIURL else { + // Value of whether the map is China map or not + public var isChinaMap : Bool!{ + guard apiBaseURL == mapboxChinaBaseAPIURL else { return false } return true } + private override init() { + super.init() + apiBaseURL = Bundle.main.object(forInfoDictionaryKey:"MGLMapboxAPIBaseURL") as? String + } + } From 87bfdea6d5c6ae0caaa3394fc8e5e0197609c21c Mon Sep 17 00:00:00 2001 From: "M.Stephen" Date: Tue, 17 Jul 2018 18:57:18 +0800 Subject: [PATCH 03/11] Update --- MapboxNavigation/NavigationMapView.swift | 2 +- MapboxNavigation/NetworkConfiguartion.swift | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/MapboxNavigation/NavigationMapView.swift b/MapboxNavigation/NavigationMapView.swift index 882de00cef..ac1e8124e5 100644 --- a/MapboxNavigation/NavigationMapView.swift +++ b/MapboxNavigation/NavigationMapView.swift @@ -946,7 +946,7 @@ open class NavigationMapView: MGLMapView, UIGestureRecognizerDelegate { to call this method on the value of `NavigationViewController.mapView`. */ @objc public func localizeLabels() { - guard NetworkConfiguration.sharedConfiguration.isChinaMap == false else{ + guard NetworkConfiguration.sharedConfiguration.hasChinaBaseURL == false else{ return } diff --git a/MapboxNavigation/NetworkConfiguartion.swift b/MapboxNavigation/NetworkConfiguartion.swift index 92c88c14d7..1fcfbd67d7 100644 --- a/MapboxNavigation/NetworkConfiguartion.swift +++ b/MapboxNavigation/NetworkConfiguartion.swift @@ -16,11 +16,11 @@ class NetworkConfiguration : NSObject{ public let mapboxChinaStyleURL = "mapbox://styles/mapbox/streets-zh-v1" // Value of whether the map is China map or not - public var isChinaMap : Bool!{ - guard apiBaseURL == mapboxChinaBaseAPIURL else { - return false + public var hasChinaBaseURL : Bool{ + if(apiBaseURL == mapboxChinaBaseAPIURL){ + return true } - return true + return false } private override init() { From d681921525cbfd64d8f1ecbeeeaccf8bcdccdfe1 Mon Sep 17 00:00:00 2001 From: "M.Stephen" Date: Wed, 18 Jul 2018 10:08:45 +0800 Subject: [PATCH 04/11] Update --- MapboxNavigation/NetworkConfiguartion.swift | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/MapboxNavigation/NetworkConfiguartion.swift b/MapboxNavigation/NetworkConfiguartion.swift index 1fcfbd67d7..7edba91d4f 100644 --- a/MapboxNavigation/NetworkConfiguartion.swift +++ b/MapboxNavigation/NetworkConfiguartion.swift @@ -17,15 +17,7 @@ class NetworkConfiguration : NSObject{ // Value of whether the map is China map or not public var hasChinaBaseURL : Bool{ - if(apiBaseURL == mapboxChinaBaseAPIURL){ - return true - } - return false - } - - private override init() { - super.init() apiBaseURL = Bundle.main.object(forInfoDictionaryKey:"MGLMapboxAPIBaseURL") as? String + return apiBaseURL == mapboxChinaBaseAPIURL } - } From d3664e5803d435f47733628c812ce2f61640e7b6 Mon Sep 17 00:00:00 2001 From: "M.Stephen" Date: Fri, 20 Jul 2018 11:21:24 +0800 Subject: [PATCH 05/11] Update for MGLExtension --- MapboxNavigation.xcodeproj/project.pbxproj | 8 +++---- MapboxNavigation/MGLAccountManager.swift | 16 ++++++++++++++ MapboxNavigation/NavigationMapView.swift | 2 +- MapboxNavigation/NetworkConfiguartion.swift | 23 --------------------- 4 files changed, 21 insertions(+), 28 deletions(-) create mode 100644 MapboxNavigation/MGLAccountManager.swift delete mode 100644 MapboxNavigation/NetworkConfiguartion.swift diff --git a/MapboxNavigation.xcodeproj/project.pbxproj b/MapboxNavigation.xcodeproj/project.pbxproj index 52525b1e08..5cd3300ac5 100644 --- a/MapboxNavigation.xcodeproj/project.pbxproj +++ b/MapboxNavigation.xcodeproj/project.pbxproj @@ -251,7 +251,7 @@ C5EF397520599120009A2C50 /* straight-line.json in Resources */ = {isa = PBXBuildFile; fileRef = C5EF397420599120009A2C50 /* straight-line.json */; }; C5F2DCA0206DBF5E002F99F6 /* Sequence.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5F2DC9F206DBF5E002F99F6 /* Sequence.swift */; }; C5F2DCA1206DBF5E002F99F6 /* Sequence.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5F2DC9F206DBF5E002F99F6 /* Sequence.swift */; }; - CFD47D9020FD85EC00BC1E49 /* NetworkConfiguartion.swift in Sources */ = {isa = PBXBuildFile; fileRef = CFD47D8F20FD85EC00BC1E49 /* NetworkConfiguartion.swift */; }; + CFD47D9020FD85EC00BC1E49 /* MGLAccountManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = CFD47D8F20FD85EC00BC1E49 /* MGLAccountManager.swift */; }; DA23C9611F4FC05C00BA9522 /* MGLMapView+MGLNavigationAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 35D825F91E6A2DBE0088F83B /* MGLMapView+MGLNavigationAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; }; DA3525702010A5210048DDFC /* Localizable.stringsdict in Resources */ = {isa = PBXBuildFile; fileRef = DA35256E2010A5200048DDFC /* Localizable.stringsdict */; }; DAAE5F301EAE4C4700832871 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = DAAE5F321EAE4C4700832871 /* Localizable.strings */; }; @@ -664,7 +664,7 @@ C5E7A31B1F4F6828001CB015 /* NavigationRouteOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationRouteOptions.swift; sourceTree = ""; }; C5EF397420599120009A2C50 /* straight-line.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "straight-line.json"; sourceTree = ""; }; C5F2DC9F206DBF5E002F99F6 /* Sequence.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Sequence.swift; sourceTree = ""; }; - CFD47D8F20FD85EC00BC1E49 /* NetworkConfiguartion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkConfiguartion.swift; sourceTree = ""; }; + CFD47D8F20FD85EC00BC1E49 /* MGLAccountManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MGLAccountManager.swift; sourceTree = ""; }; DA1811FD20128B0900C91918 /* he */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = he; path = he.lproj/Main.strings; sourceTree = ""; }; DA1811FE20128B0900C91918 /* he */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = he; path = he.lproj/Navigation.strings; sourceTree = ""; }; DA18120120128B7B00C91918 /* he */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = he; path = he.lproj/Localizable.strings; sourceTree = ""; }; @@ -917,7 +917,7 @@ 356B7D8A1EE166E100FE5B89 /* scripts */, 351BEC201E5BD4DC006FE110 /* Supporting files */, C51923B51EA55CD4002AF9E1 /* Views */, - CFD47D8F20FD85EC00BC1E49 /* NetworkConfiguartion.swift */, + CFD47D8F20FD85EC00BC1E49 /* MGLAccountManager.swift */, 3EA93A10227A7DAF1861D9F5 /* Cache.swift */, 160D8278205996DA00D278D6 /* DataCache.swift */, 35726EE71F0856E900AFA1B6 /* DayStyle.swift */, @@ -1859,7 +1859,7 @@ 35ECAF2D2092275100DC3BC3 /* UIImage.swift in Sources */, 351BEC051E5BCC6C006FE110 /* LaneView.swift in Sources */, C5A7EC5C1FD610A80008B9BA /* VisualInstructionComponent.swift in Sources */, - CFD47D9020FD85EC00BC1E49 /* NetworkConfiguartion.swift in Sources */, + CFD47D9020FD85EC00BC1E49 /* MGLAccountManager.swift in Sources */, 351BEC0D1E5BCC72006FE110 /* Bundle.swift in Sources */, 8DF399B21FB257B30034904C /* UIGestureRecognizer.swift in Sources */, 35B7837E1F9547B300291F9A /* Transitioning.swift in Sources */, diff --git a/MapboxNavigation/MGLAccountManager.swift b/MapboxNavigation/MGLAccountManager.swift new file mode 100644 index 0000000000..1fe14a586a --- /dev/null +++ b/MapboxNavigation/MGLAccountManager.swift @@ -0,0 +1,16 @@ +import Foundation +import Mapbox + +extension MGLAccountManager{ + + static let mapboxChinaBaseAPIURL = "https://api.mapbox.cn" + static let mapboxChinaBaseURLHost = "api.mapbox.cn" + static let mapboxChinaStyleURL = "mapbox://styles/mapbox/streets-zh-v1" + + // Value of whether the map is China map or not + public class var hasChinaBaseURL : Bool{ + let apiBaseURL = Bundle.main.object(forInfoDictionaryKey:"MGLMapboxAPIBaseURL") as? String + return apiBaseURL == mapboxChinaBaseAPIURL + } + +} diff --git a/MapboxNavigation/NavigationMapView.swift b/MapboxNavigation/NavigationMapView.swift index ac1e8124e5..62737153bc 100644 --- a/MapboxNavigation/NavigationMapView.swift +++ b/MapboxNavigation/NavigationMapView.swift @@ -946,7 +946,7 @@ open class NavigationMapView: MGLMapView, UIGestureRecognizerDelegate { to call this method on the value of `NavigationViewController.mapView`. */ @objc public func localizeLabels() { - guard NetworkConfiguration.sharedConfiguration.hasChinaBaseURL == false else{ + guard MGLAccountManager.hasChinaBaseURL == false else{ return } diff --git a/MapboxNavigation/NetworkConfiguartion.swift b/MapboxNavigation/NetworkConfiguartion.swift deleted file mode 100644 index 7edba91d4f..0000000000 --- a/MapboxNavigation/NetworkConfiguartion.swift +++ /dev/null @@ -1,23 +0,0 @@ -import Foundation - -class NetworkConfiguration : NSObject{ - @objc static let sharedConfiguration = NetworkConfiguration() - - // The current API base URL of map - private var apiBaseURL : String? - - // The PRC base URL for Mapbox APIs other than the telemetry API. - private let mapboxChinaBaseAPIURL = "https://api.mapbox.cn" - - // The base URL host for Mapbox China - public let mapboxChinaBaseURLHost = "api.mapbox.cn" - - // The URL String of China map style. - public let mapboxChinaStyleURL = "mapbox://styles/mapbox/streets-zh-v1" - - // Value of whether the map is China map or not - public var hasChinaBaseURL : Bool{ - apiBaseURL = Bundle.main.object(forInfoDictionaryKey:"MGLMapboxAPIBaseURL") as? String - return apiBaseURL == mapboxChinaBaseAPIURL - } -} From 2ee884cf99a4c94d5e0d6f366e2d769c1f7cdcb3 Mon Sep 17 00:00:00 2001 From: "M.Stephen" Date: Tue, 24 Jul 2018 15:59:16 +0800 Subject: [PATCH 06/11] Change the default URL of .cn map --- MapboxNavigation/MGLAccountManager.swift | 4 +++- MapboxNavigation/MGLStyle.swift | 12 +++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/MapboxNavigation/MGLAccountManager.swift b/MapboxNavigation/MGLAccountManager.swift index 1fe14a586a..02355c23be 100644 --- a/MapboxNavigation/MGLAccountManager.swift +++ b/MapboxNavigation/MGLAccountManager.swift @@ -1,11 +1,13 @@ import Foundation import Mapbox + extension MGLAccountManager{ static let mapboxChinaBaseAPIURL = "https://api.mapbox.cn" static let mapboxChinaBaseURLHost = "api.mapbox.cn" - static let mapboxChinaStyleURL = "mapbox://styles/mapbox/streets-zh-v1" + 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 public class var hasChinaBaseURL : Bool{ diff --git a/MapboxNavigation/MGLStyle.swift b/MapboxNavigation/MGLStyle.swift index 2b848cba71..a47eabe6ea 100644 --- a/MapboxNavigation/MGLStyle.swift +++ b/MapboxNavigation/MGLStyle.swift @@ -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"))! } } // 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"))! } } @objc // Returns the URL to the given version of the navigation guidance style. Available version are 1, 2, and 3. 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)"))! } } From f701580b9f4500be14cdcf29c5fc1016a904e042 Mon Sep 17 00:00:00 2001 From: "M.Stephen" Date: Wed, 25 Jul 2018 10:08:34 +0800 Subject: [PATCH 07/11] Documentation and move style constants into MGLStyle extension. --- MapboxNavigation/MGLAccountManager.swift | 10 +++-- MapboxNavigation/MGLStyle.swift | 57 ++++++++++++++++++++---- 2 files changed, 55 insertions(+), 12 deletions(-) diff --git a/MapboxNavigation/MGLAccountManager.swift b/MapboxNavigation/MGLAccountManager.swift index 02355c23be..14297d180d 100644 --- a/MapboxNavigation/MGLAccountManager.swift +++ b/MapboxNavigation/MGLAccountManager.swift @@ -4,12 +4,16 @@ import Mapbox extension MGLAccountManager{ + // Mapbox China base API URL static let mapboxChinaBaseAPIURL = "https://api.mapbox.cn" + + //Mapbox China base URL host. 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 + /** + The value of whether the map is China map or not + */ + @objc public class var hasChinaBaseURL : Bool{ let apiBaseURL = Bundle.main.object(forInfoDictionaryKey:"MGLMapboxAPIBaseURL") as? String return apiBaseURL == mapboxChinaBaseAPIURL diff --git a/MapboxNavigation/MGLStyle.swift b/MapboxNavigation/MGLStyle.swift index a47eabe6ea..7dca472712 100644 --- a/MapboxNavigation/MGLStyle.swift +++ b/MapboxNavigation/MGLStyle.swift @@ -3,24 +3,63 @@ import Mapbox extension MGLStyle { - // Returns the URL to the current version of the Mapbox Navigation Guidance Day style. + + // The Mapbox China Day Style URL. + static let mapboxChinaDayStyleURL = URL(string:"mapbox://styles/mapbox/streets-zh-v1")! + + // The Mapbox China Night Style URL. + static let mapboxChinaNightStyleURL = URL(string:"mapbox://styles/mapbox/dark-zh-v1")! + + /** + Returns the URL to the current version of the Mapbox Navigation Guidance Day style. + */ @objc - public class var navigationGuidanceDayStyleURL: URL { get { return URL(string: (MGLAccountManager.hasChinaBaseURL ? MGLAccountManager.mapboxChinaDayStyleURL : "mapbox://styles/mapbox/navigation-guidance-day-v2"))! } } + public class var navigationGuidanceDayStyleURL: URL { + get { + if(MGLAccountManager.hasChinaBaseURL){ + return mapboxChinaDayStyleURL + } + return URL(string:"mapbox://styles/mapbox/navigation-guidance-day-v2")! + } + } - // Returns the URL to the current version of the Mapbox Navigation Guidance Night style. + /** + Returns the URL to the current version of the Mapbox Navigation Guidance Night style. + */ @objc - public class var navigationGuidanceNightStyleURL: URL { get { return URL(string: (MGLAccountManager.hasChinaBaseURL ? MGLAccountManager.mapboxChinaNightStyleURL : "mapbox://styles/mapbox/navigation-guidance-night-v2"))! } } + public class var navigationGuidanceNightStyleURL: URL { + get { + if(MGLAccountManager.hasChinaBaseURL){ + return mapboxChinaDayStyleURL + } + return URL(string:"mapbox://styles/mapbox/navigation-guidance-night-v2")! + } + } + /** + Returns the URL to the given version of the navigation guidance style. Available version are 1, 2, and 3. + + We only have one version of navigation guidance style in China, so if you switch your endpoint to .cn, it will return the default day style. + */ @objc - // Returns the URL to the given version of the navigation guidance style. Available version are 1, 2, and 3. public class func navigationGuidanceDayStyleURL(version: Int) -> URL { - return URL(string: (MGLAccountManager.hasChinaBaseURL ? MGLAccountManager.mapboxChinaDayStyleURL :"mapbox://styles/mapbox/navigation-guidance-day-v\(version)"))! + if(MGLAccountManager.hasChinaBaseURL){ + return mapboxChinaDayStyleURL + } + return URL(string:"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. + /** + Returns the URL to the given version of the navigation guidance style. Available version are 2, and 3. + + We only have one version of navigation guidance style in China, so if you switch your endpoint to .cn, it will return the default night style. + */ + @objc public class func navigationGuidanceNightStyleURL(version: Int) -> URL { - return URL(string: (MGLAccountManager.hasChinaBaseURL ? MGLAccountManager.mapboxChinaNightStyleURL :"mapbox://styles/mapbox/navigation-guidance-night-v\(version)"))! + if(MGLAccountManager.hasChinaBaseURL){ + return mapboxChinaNightStyleURL + } + return URL(string: "mapbox://styles/mapbox/navigation-guidance-night-v\(version)")! } } From 3688c3be48c052b2cbe8919f6cbac6bc9ab2f02f Mon Sep 17 00:00:00 2001 From: "M.Stephen" Date: Wed, 25 Jul 2018 10:16:46 +0800 Subject: [PATCH 08/11] Add documentation full stop. --- MapboxNavigation/MGLAccountManager.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MapboxNavigation/MGLAccountManager.swift b/MapboxNavigation/MGLAccountManager.swift index 14297d180d..89b07bc2f0 100644 --- a/MapboxNavigation/MGLAccountManager.swift +++ b/MapboxNavigation/MGLAccountManager.swift @@ -11,7 +11,7 @@ extension MGLAccountManager{ static let mapboxChinaBaseURLHost = "api.mapbox.cn" /** - The value of whether the map is China map or not + The value of whether the map is China map or not. */ @objc public class var hasChinaBaseURL : Bool{ From d59a4280f600edc05e7fc436ca594687d14a7397 Mon Sep 17 00:00:00 2001 From: "M.Stephen" Date: Wed, 25 Jul 2018 10:19:16 +0800 Subject: [PATCH 09/11] Modify documentation. --- MapboxNavigation/MGLAccountManager.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MapboxNavigation/MGLAccountManager.swift b/MapboxNavigation/MGLAccountManager.swift index 89b07bc2f0..c01a01a1de 100644 --- a/MapboxNavigation/MGLAccountManager.swift +++ b/MapboxNavigation/MGLAccountManager.swift @@ -11,7 +11,7 @@ extension MGLAccountManager{ static let mapboxChinaBaseURLHost = "api.mapbox.cn" /** - The value of whether the map is China map or not. + Returns true if the map's endpoint is China. */ @objc public class var hasChinaBaseURL : Bool{ From a064cc89f2201b5f4a8c5a71ab2ae40c24a53236 Mon Sep 17 00:00:00 2001 From: "M.Stephen" Date: Wed, 25 Jul 2018 10:23:29 +0800 Subject: [PATCH 10/11] Update --- MapboxNavigation/MGLAccountManager.swift | 3 +-- MapboxNavigation/MGLStyle.swift | 12 ++++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/MapboxNavigation/MGLAccountManager.swift b/MapboxNavigation/MGLAccountManager.swift index c01a01a1de..afe4198b7d 100644 --- a/MapboxNavigation/MGLAccountManager.swift +++ b/MapboxNavigation/MGLAccountManager.swift @@ -13,8 +13,7 @@ extension MGLAccountManager{ /** Returns true if the map's endpoint is China. */ - @objc - public class var hasChinaBaseURL : Bool{ + @objc public class var hasChinaBaseURL : Bool{ let apiBaseURL = Bundle.main.object(forInfoDictionaryKey:"MGLMapboxAPIBaseURL") as? String return apiBaseURL == mapboxChinaBaseAPIURL } diff --git a/MapboxNavigation/MGLStyle.swift b/MapboxNavigation/MGLStyle.swift index 7dca472712..3482ddea5a 100644 --- a/MapboxNavigation/MGLStyle.swift +++ b/MapboxNavigation/MGLStyle.swift @@ -13,8 +13,7 @@ extension MGLStyle { /** Returns the URL to the current version of the Mapbox Navigation Guidance Day style. */ - @objc - public class var navigationGuidanceDayStyleURL: URL { + @objc public class var navigationGuidanceDayStyleURL: URL { get { if(MGLAccountManager.hasChinaBaseURL){ return mapboxChinaDayStyleURL @@ -26,8 +25,7 @@ extension MGLStyle { /** Returns the URL to the current version of the Mapbox Navigation Guidance Night style. */ - @objc - public class var navigationGuidanceNightStyleURL: URL { + @objc public class var navigationGuidanceNightStyleURL: URL { get { if(MGLAccountManager.hasChinaBaseURL){ return mapboxChinaDayStyleURL @@ -41,8 +39,7 @@ extension MGLStyle { We only have one version of navigation guidance style in China, so if you switch your endpoint to .cn, it will return the default day style. */ - @objc - public class func navigationGuidanceDayStyleURL(version: Int) -> URL { + @objc public class func navigationGuidanceDayStyleURL(version: Int) -> URL { if(MGLAccountManager.hasChinaBaseURL){ return mapboxChinaDayStyleURL } @@ -55,8 +52,7 @@ extension MGLStyle { We only have one version of navigation guidance style in China, so if you switch your endpoint to .cn, it will return the default night style. */ - @objc - public class func navigationGuidanceNightStyleURL(version: Int) -> URL { + @objc public class func navigationGuidanceNightStyleURL(version: Int) -> URL { if(MGLAccountManager.hasChinaBaseURL){ return mapboxChinaNightStyleURL } From cfe94738c9c4606f76b0ac1faf306f9d5d6674ab Mon Sep 17 00:00:00 2001 From: "M.Stephen" Date: Wed, 25 Jul 2018 10:49:35 +0800 Subject: [PATCH 11/11] Adding change log : Map labels are no longer blank and using China Map Style URLs if the application is configured to use Mapbox China APIs. [#1558](https://github.com/mapbox/mapbox-navigation-ios/pull/1558) --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a487b3fa2c..ef03c8d822 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## master +* Map labels are no longer blank and using China Map Style URLs if the application is configured to use Mapbox China APIs. [#1558](https://github.com/mapbox/mapbox-navigation-ios/pull/1558) + ### Packaging * Moved guides and examples to [a new Mapbox Navigation SDK for iOS website](https://www.mapbox.com/ios-sdk/navigation/). ([#1552](https://github.com/mapbox/mapbox-navigation-ios/pull/1552))