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 sessiontoken and sparse fields #867

Merged
merged 4 commits into from
Jul 19, 2018
Merged
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion src/util/googleMaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ export const getPlaceDetails = (placeId, sessionToken) =>
const serviceStatus = window.google.maps.places.PlacesServiceStatus;
const el = document.createElement('div');
const service = new window.google.maps.places.PlacesService(el);
const fields = ['address_component', 'formatted_address', 'geometry', 'place_id'];
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't the place_id known already?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but it doesn't hurt to have that returned also (it's part of the basic fields => same pricing). Anyway, id's included to the return object makes them easier to be reused in Redux store if that kind of feature is needed.

const sessionTokenMaybe = sessionToken ? { sessionToken } : {};

service.getDetails({ placeId, ...sessionTokenMaybe }, (place, status) => {
service.getDetails({ placeId, fields, ...sessionTokenMaybe }, (place, status) => {
if (status !== serviceStatus.OK) {
reject(
new Error(`Could not get details for place id "${placeId}", error status was "${status}"`)
Expand Down