Skip to content

Add Directions API beta query parameters example#106

Merged
jill-cardamon merged 6 commits into
mainfrom
jill/beta-query-parameters-91
Jul 27, 2021
Merged

Add Directions API beta query parameters example#106
jill-cardamon merged 6 commits into
mainfrom
jill/beta-query-parameters-91

Conversation

@jill-cardamon
Copy link
Copy Markdown
Contributor

@jill-cardamon jill-cardamon commented May 4, 2021

Adds an example to demonstrate how to use the new Directions API beta query parameters. This issue closes #91.

let items = [URLQueryItem(name: "depart_at", value: departureTime)]
print("!!! departure time: \(String(describing: departureTime))")
if let queryItems = super.urlQueryItems as [URLQueryItem]? {
print("!!! queryItems: \(queryItems)")
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Remember to remove print statements and comments.

@jill-cardamon jill-cardamon linked an issue May 4, 2021 that may be closed by this pull request
@jill-cardamon jill-cardamon force-pushed the jill/beta-query-parameters-91 branch from 6b26740 to 8211d8a Compare June 10, 2021 13:23
@jill-cardamon jill-cardamon marked this pull request as ready for review June 10, 2021 13:23
@jill-cardamon jill-cardamon requested a review from 1ec5 June 29, 2021 14:37
@jill-cardamon jill-cardamon requested a review from a team July 13, 2021 14:35

startButton.bottomAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.bottomAnchor, constant: -20).isActive = true
startButton.centerXAnchor.constraint(equalTo: self.view.centerXAnchor).isActive = true
view.setNeedsLayout()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think it is necessary. It will be due to layout automatically.

startButton.isHidden = true
view.addSubview(startButton)

startButton.bottomAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.bottomAnchor, constant: -20).isActive = true
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: There is a nice short cut to active constraints:

NSLayoutConstraint.active([
/* a list of constraints */
])

Comment on lines +170 to +173
let item = [URLQueryItem(name: "depart_at", value: departureTime)]
if let queryItems = super.urlQueryItems as [URLQueryItem]? {
return queryItems + item
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

super.urlQueryItems is always [URLQueryItem]. There is no need for a cast.

Suggested change
let item = [URLQueryItem(name: "depart_at", value: departureTime)]
if let queryItems = super.urlQueryItems as [URLQueryItem]? {
return queryItems + item
}
var items = super.urlQueryItems
items.append(URLQueryItem(name: "depart_at", value: departureTime))
return items

Comment thread Navigation-Examples/Examples/Beta-Query-Parameters.swift
@jill-cardamon jill-cardamon self-assigned this Jul 27, 2021
@jill-cardamon jill-cardamon force-pushed the jill/beta-query-parameters-91 branch from 4197c6e to e33768b Compare July 27, 2021 14:50
@jill-cardamon jill-cardamon changed the base branch from release-v2.0 to main July 27, 2021 14:57
@jill-cardamon jill-cardamon merged commit 311ca62 into main Jul 27, 2021
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.

Add example of using Directions API beta query parameters

2 participants