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

Republicize DirectionsOptions.urlQueryItems #461

Merged
merged 1 commit into from
Sep 15, 2020
Merged

Conversation

1ec5
Copy link
Contributor

@1ec5 1ec5 commented Sep 15, 2020

Made DirectionsOptions.urlQueryItems open once again.

Fixes #460.

/cc @mapbox/navigation-ios @jmkiley @captainbarbosa @geografa

@1ec5 1ec5 added this to the v1.0.0 milestone Sep 15, 2020
@1ec5 1ec5 requested a review from Udumft September 15, 2020 02:48
@1ec5 1ec5 self-assigned this Sep 15, 2020
@1ec5
Copy link
Contributor Author

1ec5 commented Sep 15, 2020

Once this PR lands, you’ll be able to try out the Mapbox Directions API’s depart_at parameter (currently in beta) by subclassing RouteOptions (or NavigationRouteOptions if you’re using the navigation SDK). For example, this RouteOptions subclass requests directions for a trip that would begin an hour from now:

// Subclass NavigationRouteOptions instead if using the navigation SDK
class DeferredRouteOptions: RouteOptions {
    var startDate = Date()
    
    override open var urlQueryItems: [URLQueryItem] {
        let startTimestamp = ISO8601DateFormatter().string(from: startDate, timeZone: .autoupdatingCurrent)
        return super.urlQueryItems + [
            URLQueryItem(name: "depart_at", value: startTimestamp),
        ]
    }
}

let options = DeferredRouteOptions(coordinates: coordinates, profileIdentifier: .automobile)
options.startDate = Date() + 60 * 60

@1ec5 1ec5 merged commit c3261f2 into master Sep 15, 2020
@1ec5 1ec5 deleted the 1ec5-open-inquery-460 branch September 15, 2020 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Subclasses of DirectionsOptions cannot override urlQueryItems
2 participants