Skip to content

usePlacesAutocompleteService not returning "geometry.location" #154

Open
@productpeter

Description

@productpeter

This 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?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions