Skip to content

Comments

Separate custom UI example#301

Merged
ericrwolfe merged 8 commits intomasterfrom
two-examples
Jun 23, 2017
Merged

Separate custom UI example#301
ericrwolfe merged 8 commits intomasterfrom
two-examples

Conversation

@bsudekum
Copy link
Contributor

simulator screen shot jun 21 2017 2 59 17 pm

todo:

  • figure out tab bar
    • toggle simulation in both examples
    • icons
    • setting selected

/cc @frederoni @1ec5 @ericrwolfe

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class name should end with ViewController, however, CustomNavigationViewController sounds like it's a subclass of NavigationViewController which is misleading.

@ericrwolfe
Copy link
Contributor

@bsudekum I've picked this up and will continue work on this tomorrow.

@ericrwolfe ericrwolfe self-assigned this Jun 22, 2017
@ericrwolfe
Copy link
Contributor

@bsudekum or @frederoni want to take a 👀 when you have a chance?

if let upComingStep = routeProgress.currentLegProgress.upComingStep {
// Don't give full instruction with distance if the alert type is high
if alertLevel == .high {
text = upComingStep.instructions
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, indent off here and line #74

guard let style = mapView.style else { return }
guard let userRoute = userRoute else { return }

mapView.addAnnotation(destination)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll also want to clear the map of all annotations before adding a new destination.

}
}

func speak(_ text: String) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is only used in one place, I think we can remove this function and move it up to where speak() is called.

let lineCasing = MGLLineStyleLayer(identifier: identifier, source: source)
// MARK: - Navigation with multiple waypoints

func startMultipleWaypoints() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since waypoints is coming through the pipeline in #270, do you think we should hold off on showing developers this method for doing multi-leg routes? It's slightly an antipattern.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's put this in for now for customers who are asking about multiple destinations.

This example serves both to show how to handle multiple destinations, but also how to display a custom UI over navigation and how to update the route on the fly.

Once this is in master, can you rebase #270 and update the example with how to implement the same concept with waypoints?

camera.heading = location.course
}
}
navigationViewController.pendingCamera = camera
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting the initial camera should be added back

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason this isn't handled by the SDK by default? NavigationViewController should automatically set the pending camera to the currentLocation || route origin's location and initial bearing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this should be possible.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RouteMapViewController.viewWillAppear(_:) falls back to calling setDefaultCamera(_:), which only sets the altitude and pitch. It would be feasible for this method to also set the center coordinate to the route’s initial location and heading. However, it wouldn’t be feasible to set the camera to the user’s current location right off the bat, because the location manager determines the current location asynchronously.

Before this PR lands, we should modify setDefaultCamera(_:) to account for the route’s origin.

Copy link
Contributor

@1ec5 1ec5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to double-check that the initial camera is reasonable. Otherwise, this looks good.

options.profileIdentifier = .automobileAvoidingTraffic

_ = Directions.shared.calculate(options) { [weak self] (waypoints, routes, error) in
_ = Directions.shared.calculate(options) { (waypoints, routes, error) in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, why has self gone from weak to strong here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yeah should [weak self] since Directions.shared is a singleton.

// MARK: - Basic Navigation

func startBasicNavigation() {
guard let route = self.currentRoute else { return }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: drop self..

camera.heading = location.course
}
}
navigationViewController.pendingCamera = camera
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RouteMapViewController.viewWillAppear(_:) falls back to calling setDefaultCamera(_:), which only sets the altitude and pitch. It would be feasible for this method to also set the center coordinate to the route’s initial location and heading. However, it wouldn’t be feasible to set the camera to the user’s current location right off the bat, because the location manager determines the current location asynchronously.

Before this PR lands, we should modify setDefaultCamera(_:) to account for the route’s origin.

])
options.includesSteps = true
options.routeShapeResolution = .full
options.profileIdentifier = .automobileAvoidingTraffic
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get these details from the previous route’s routeOptions? That way, if the profile happens to be .cycling, it’ll automatically match when going to the next leg of the trip.

}
return parent.pendingCamera
}
var defaultCamera: MGLMapCamera {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more like tiltedCamera or cameraFacingRoad, since it’s a dynamic value rather than a fixed value.

@ericrwolfe ericrwolfe merged commit 2c6ec67 into master Jun 23, 2017
@ericrwolfe ericrwolfe deleted the two-examples branch June 23, 2017 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants