Skip to content
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

Add completion handlers to camera change operations #2192

Merged
merged 3 commits into from
Jul 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
binary "https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json" "5.1.0"
binary "https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json" "5.2.0"
binary "https://www.mapbox.com/ios-sdk/MapboxNavigationNative.json" "6.2.1"
github "AndriiDoroshko/SnappyShrimp" "1.6.4"
github "CedarBDD/Cedar" "v1.0"
Expand Down
2 changes: 1 addition & 1 deletion Example/OfflineViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class OfflineViewController: UIViewController, MGLMapViewDelegate {
}

func mapViewDidFinishLoadingMap(_ mapView: MGLMapView) {
mapView.setUserTrackingMode(.follow, animated: false)
mapView.setUserTrackingMode(.follow, animated: false, completionHandler: nil)
mapView.setZoomLevel(8, animated: false)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@
"${PODS_ROOT}/Target Support Files/Pods-PodInstall/Pods-PodInstall-frameworks.sh",
"${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/Mapbox.framework",
"${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/Mapbox.framework.dSYM",
"${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/E3F066DB-FB3F-3DB3-ADCA-FD22D28B3593.bcsymbolmap",
"${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/314B394E-4B8A-3249-ACB5-C8B038156249.bcsymbolmap",
"${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/1BF93521-4C77-3633-A539-01336F1D64E9.bcsymbolmap",
"${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/9D189C8A-78FE-3297-847F-34B05A3A6906.bcsymbolmap",
"${BUILT_PRODUCTS_DIR}/MapboxCoreNavigation/MapboxCoreNavigation.framework",
"${BUILT_PRODUCTS_DIR}/MapboxDirections.swift/MapboxDirections.framework",
"${BUILT_PRODUCTS_DIR}/MapboxMobileEvents/MapboxMobileEvents.framework",
Expand All @@ -248,8 +248,8 @@
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Mapbox.framework",
"${DWARF_DSYM_FOLDER_PATH}/Mapbox.framework.dSYM",
"${BUILT_PRODUCTS_DIR}/E3F066DB-FB3F-3DB3-ADCA-FD22D28B3593.bcsymbolmap",
"${BUILT_PRODUCTS_DIR}/314B394E-4B8A-3249-ACB5-C8B038156249.bcsymbolmap",
"${BUILT_PRODUCTS_DIR}/1BF93521-4C77-3633-A539-01336F1D64E9.bcsymbolmap",
"${BUILT_PRODUCTS_DIR}/9D189C8A-78FE-3297-847F-34B05A3A6906.bcsymbolmap",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxCoreNavigation.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxDirections.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxMobileEvents.framework",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- Mapbox-iOS-SDK (5.1.0)
- Mapbox-iOS-SDK (5.2.0)
- MapboxCoreNavigation (0.35.0):
- MapboxDirections.swift (~> 0.28.0)
- MapboxMobileEvents (~> 0.9.5)
Expand Down Expand Up @@ -41,7 +41,7 @@ EXTERNAL SOURCES:
:path: "../../../"

SPEC CHECKSUMS:
Mapbox-iOS-SDK: 4106f0f6808a0362233a703fb22369b3af3e9b8c
Mapbox-iOS-SDK: 3e095b305126d52ba166fe215d847b15b6fbee63
MapboxCoreNavigation: 840a7699306d24f5fc7eeb64e018b926d5ff693e
MapboxDirections.swift: bec8771badfbdd55a0194649a4194b2c2cb15b96
MapboxMobileEvents: f6c21b2e59066c5c7093585de7c15adae3b63da0
Expand Down
5 changes: 3 additions & 2 deletions MapboxNavigation/CarPlayManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ extension CarPlayManager: CPInterfaceControllerDelegate {
let mapView = mapViewController.mapView
mapView.removeRoutes()
mapView.removeWaypoints()
mapView.setUserTrackingMode(.followWithCourse, animated: true)
mapView.setUserTrackingMode(.followWithCourse, animated: true, completionHandler: nil)
}
}
public func templateWillDisappear(_ template: CPTemplate, animated: Bool) {
Expand Down Expand Up @@ -630,7 +630,8 @@ extension CarPlayManager: CPMapTemplateDelegate {
return
}

mapView.setContentInset(mapView.safeArea, animated: false) //make sure this is always up to date in-case safe area changes during gesture
// Make sure the content inset is always up to date in case the safe area changes during a gesture.
mapView.setContentInset(mapView.safeArea, animated: false, completionHandler: nil)
updatePan(by: translation, mapTemplate: mapTemplate, animated: false)
}

Expand Down
11 changes: 8 additions & 3 deletions MapboxNavigation/CarPlayMapViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class CarPlayMapViewController: UIViewController {
@objc public lazy var recenterButton: CPMapButton = {
let recenter = CPMapButton { [weak self] button in

self?.mapView.setUserTrackingMode(.followWithCourse, animated: true)
self?.mapView.setUserTrackingMode(.followWithCourse, animated: true, completionHandler: nil)
button.isHidden = true
}
let bundle = Bundle.mapboxNavigation
Expand Down Expand Up @@ -204,14 +204,19 @@ public class CarPlayMapViewController: UIViewController {
edgePadding += UIEdgeInsets(top: midY, left: midX, bottom: midY, right: midX)
}

mapView.setContentInset(edgePadding, animated: false)
mapView.setContentInset(edgePadding, animated: false, completionHandler: nil)

guard let active = mapView.routes?.first else {
mapView.setUserTrackingMode(.followWithCourse, animated: true)
mapView.setUserTrackingMode(.followWithCourse, animated: true, completionHandler: nil)
return
}

if isOverviewingRoutes {
//FIXME: Unable to tilt map during route selection -- https://github.com/mapbox/mapbox-gl-native/issues/2259
let topDownCamera = mapView.camera
topDownCamera.pitch = 0
mapView.setCamera(topDownCamera, animated: false)

mapView.fit(to: active, animated: false)
}
}
Expand Down
10 changes: 3 additions & 7 deletions MapboxNavigation/CarPlayNavigationViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,9 @@ public class CarPlayNavigationViewController: UIViewController, NavigationMapVie

mapView.enableFrameByFrameCourseViewTracking(for: 1)

mapView.setContentInset(view.safeArea, animated: true)

if !tracksUserCourse {
// TODO: chain mapView.fit(to:facing:animated:) to the completion of
// setContentInset(_:animated:completion) when
// https://github.com/mapbox/mapbox-gl-native/pull/14381 lands
mapView.fit(to: navigationService.route, facing: 0, animated: false)
mapView.setContentInset(view.safeArea, animated: true) { [weak self] in
guard let self = self, self.tracksUserCourse else { return }
mapView.fit(to: self.navigationService.route, facing: 0, animated: true)
}
}

Expand Down
2 changes: 1 addition & 1 deletion MapboxNavigation/NavigationMapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ open class NavigationMapView: MGLMapView, UIGestureRecognizerDelegate {
func fit(to route: Route, facing direction:CLLocationDirection = 0, animated: Bool = false) {
guard let coords = route.coordinates, !coords.isEmpty else { return }

setUserTrackingMode(.none, animated: false)
setUserTrackingMode(.none, animated: false, completionHandler: nil)
let line = MGLPolyline(coordinates: coords, count: UInt(coords.count))
let camera = cameraThatFitsShape(line, direction: direction, edgePadding: .zero)

Expand Down
2 changes: 1 addition & 1 deletion MapboxNavigation/RouteMapViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ class RouteMapViewController: UIViewController {

override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
mapView.setContentInset(contentInset(forOverviewing: isInOverviewMode), animated: true)
mapView.setContentInset(contentInset(forOverviewing: isInOverviewMode), animated: true, completionHandler: nil)
mapView.setNeedsUpdateConstraints()
}

Expand Down