usePlacesAutocompleteService not returning "geometry.location"
See original GitHub issueThis is the code I’m using to configure usePlacesAutocompleteService
const {
placePredictions,
getPlacePredictions,
isPlacePredictionsLoading,
} = useGoogle({
apiKey: API_KEY,
language: "en",
debounce: 500,
options: {
types: [],
componentRestrictions: { country: "ca" },
fields: [
"address_components",
"geometry.location",
"place_id",
"formatted_address",
]
}
});
This is my response
description: "CN Tower, Bremner Boulevard, Toronto, ON, Canada"
matched_substrings: [{…}]
place_id: "ChIJmzrzi9Y0K4gRgXUc3sTY7RU"
reference: "ChIJmzrzi9Y0K4gRgXUc3sTY7RU"
structured_formatting: {main_text: 'CN Tower', main_text_matched_substrings: Array(1), secondary_text: 'Bremner Boulevard, Toronto, ON, Canada'}
terms: (5) [{…}, {…}, {…}, {…}, {…}]
types: (3) ['tourist_attraction', 'point_of_interest', 'establishment']
The intended response should be
address_components: (8) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
formatted_address: "290 Bremner Blvd, Toronto, ON M5V 3L9, Canada"
geometry: {location: _.Ee}
html_attributions: []
place_id: "ChIJmzrzi9Y0K4gRgXUc3sTY7RU"
Does google not allow such queries?
If so, is my only alternative (without using usePlacesWidget) to get LatLng via Google Map’s Geocoding / Places API?
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Place Autocomplete | Maps JavaScript API - Google Developers
You can use the returned place ID with calls to the Places, Geocoding, Directions or Distance Matrix services. Note: The name property will...
Read more >Google places api not returning geometry - Stack Overflow
Map worked fine and returned geometry yesterday, today it is just blank, ... addListener('place_changed', function () { var place = service.
Read more >How to Use Places Autocomplete Google API - W3docs
The service can be used to provide an autocomplete functionality for text-based geographic searches by returning places such as businesses, addresses and points ......
Read more >Bug: Not receiving geometry.location for some addresses ...
Marie, ON, Canada" into places search box, click on the provided list item. 4. a place object is returned that doesn't contain a...
Read more >react-native-google-places-autocomplete - npm
... "Google Places API Web Service" (NOT Android or iOS) in the console. ... from autocomplete if the place details api return not...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just call
lat()
andlng()
usingPlacesService
Hey @dcruz1990 you should be able to get lat/lng by calling Google Map’s Geocoding / Places API separately or use a different library with geometry support. I was more concerned with the fact that I couldn’t utilize session token with this approach.
Keep in mind that whenever an Autocomplete request is called, a session token can be generated which is used along side of a subsequent Place Details call to save money!
usePlacesWidget provided by the package uses session token (and returns lat/lng) by default, however, you can’t customize the UI all that much.
Here are some documents on session tokens: https://developers.google.com/maps/documentation/places/web-service/session-tokens https://developers.google.com/maps/documentation/places/web-service/details#session_tokens
Best of luck!