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

Adds Geocode API for searching places #583

Closed
wants to merge 6 commits into from

Conversation

pamegonzalez
Copy link

This adds Geocode API for searching places as an alternative for place/search request.

@bell-steven
Copy link
Collaborator

Hi, thanks for the PR. Would you mind giving me a little more background for the changes in this PR? What is the problem that you are trying to solve, and why is this the right solution?

@pamegonzalez
Copy link
Author

Hi, thanks for the PR. Would you mind giving me a little more background for the changes in this PR? What is the problem that you are trying to solve, and why is this the right solution?

Hi! I'm sorry. We've been receiving charges for using atmosphere data and contact data even when we are sending the correct basic fields in the request. We don't know why and to avoid this we prefer using Geocode API because it gives us just the parameters we need: address_components, formatted_address and geometry. Geocode API is a cheaper alternative to Places Search API 😄

Maybe this could be useful for other developers!

@bell-steven
Copy link
Collaborator

bell-steven commented Jul 8, 2020

My understanding from looking at your code is that you want to provide an additional option in step 2, where instead of querying the Place Details API, you would query the Geocode API. Is this correct?

Are you using the GooglePlacesDetailsQuery prop to specify the fields that you want from the Place Details API (see here for more)? Something like this:

      <GooglePlacesAutocomplete
        placeholder="Search"
        fetchDetails
        onPress={(data, details = null) => {
          console.log(data, details);
        }}
        onNotFound={() => console.log("not Found")}
        query={{
          key: GOOGLE_PLACES_API_KEY,
          language: "en", // language of the results
        }}
        GooglePlacesDetailsQuery={{
          fields: "address_components,formatted_address,geometry",
        }}
      />

In terms of merging this PR, I have a few questions.

  1. is the Geocode API cheaper than using the Place details API if you use the GooglePlacesDetailsQuery?
  2. is there any data that the Geocode API returns that you cannot get from the Place Details API?

@pamegonzalez
Copy link
Author

pamegonzalez commented Jul 8, 2020

My understanding from looking at your code is that you want to provide an additional option in step 2, where instead of querying the Place Details API, you would query the Geocode API. Is this correct?

Are you using the GooglePlacesDetailsQuery prop to specify the fields that you want from the Place Details API (see here for more)? Something like this:

      <GooglePlacesAutocomplete
        placeholder="Search"
        fetchDetails
        onPress={(data, details = null) => {
          console.log(data, details);
        }}
        onNotFound={() => console.log("not Found")}
        query={{
          key: GOOGLE_PLACES_API_KEY,
          language: "en", // language of the results
        }}
        GooglePlacesDetailsQuery={{
          fields: "address_components,formatted_address,geometry",
        }}
      />

In terms of merging this PR, I have a few questions.

  1. is the Geocode API cheaper than using the Place details API if you use the GooglePlacesDetailsQuery?
  2. is there any data that the Geocode API returns that you cannot get from the Place Details API?

Let me answer all your questions 😄

  • you want to provide an additional option in step 2, where instead of querying the Place Details API, you would query the Geocode API. Is this correct?

Yes! I meant the Place Details API, not Search, I'm sorry for the confusion.

  • Are you using the GooglePlacesDetailsQuery prop to specify the fields that you want from the Place Details API

Yes, I am. I'm only querying address_components, formatted_address and geometry and I'm only receiving those fields as response. I don't know why the hell I'm getting charges for Atmosphere and Contact Data.

  • is the Geocode API cheaper than using the Place details API if you use the GooglePlacesDetailsQuery?

Yes, Geocode API pricing is $4 every 1K requests for +100K requests per month and Place Details is $13,60 every 1K requests for 100K - 500K requests per month. For less than 100k request per month the cost is $5 and $17 respectively for every 1K requests.
As you can see the difference is huge!

  • is there any data that the Geocode API returns that you cannot get from the Place Details API?

No, actually, Geocoding API for details search only retrieves address_components, formatted_address and geometry as result. Is a simpler request with no extra charges!

@bell-steven
Copy link
Collaborator

Thanks for the thorough explanations!

At this point, I am inclined to wait until v2 to include this, as the functionality is technically available with the GooglePlacesDetailsQuery prop.

@bell-steven bell-steven added this to the 2.0.0 milestone Jul 8, 2020
@pamegonzalez
Copy link
Author

Thanks for the thorough explanations!

At this point, I am inclined to wait until v2 to include this, as the functionality is technically available with the GooglePlacesDetailsQuery prop.

Thanks! When is the V2 gonna be released? Really looking forward to it!

@bell-steven
Copy link
Collaborator

"When it's ready" is the standard open source answer.

Feel free to take a look at the roadmap issue (#552) and create pulls against the v2 branch.

@pamegonzalez pamegonzalez changed the base branch from master to v2 July 8, 2020 15:55
@frangeris
Copy link

@pamegonzalez just a quick note about choosing Geocode over Places api, Geocoding is not meant to return multiple queries and is not a replacement for Places API.

From FAQ:

https://developers.google.com/maps/documentation/geocoding/faq#trbl_component_filtering

When dealing with user input of addresses, the Place Autocomplete feature in the Places API may produce better quality results. Place Autocomplete is optimized to be used interactively, and thus has very low latency.

Address geocoding in the Geocoding API is optimized for use with complete, unambiguous, well formatted addresses, such as delivery addresses entered into online forms, and thus has higher latency than Place Autocomplete. The forward geocoder has greater coverage and better result quality, but with somewhat higher latency.

I'm not sure if implement geocoding could be a good approach here, maybe in a different package could sounds better...

@bell-steven bell-steven closed this Oct 8, 2020
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.

5 participants